Пример #1
0
		// http://msdn.microsoft.com/en-us/library/system.windows.controls.openfiledialog(VS.95).aspx
		// http://msdn.microsoft.com/en-us/library/microsoft.win32.openfiledialog.aspx
		// http://blog.everythingflex.com/2008/10/01/filereferencesave-in-flash-player-10/
		
		// at 2009.06.05 silverlight cannot use save file dialog

		// Only one file browsing session may be performed at a time.

		public void Open(Action<MemoryStream> handler)
		{
			1.AtDelay(
				delegate
				{
					var s = new Microsoft.Win32.OpenFileDialog();

					if (s.ShowDialog() ?? false)
					{
						var m = new MemoryStream();

						using (var r = s.OpenFile())
						{
							var buffer = new byte[r.Length];

							r.Read(buffer, 0, buffer.Length);

							m.Write(buffer, 0, buffer.Length);
						}

						handler(m);
					}
				}
			);
		}
Пример #2
0
        private async void ExecuteOpenDocumentCommand(object o)
        {
            var saveDialog = new Microsoft.Win32.OpenFileDialog();

            saveDialog.Filter = "TakoDeploy Document (*.tdd)|*.tdd|All files (*.*)|*.*";
            var result = saveDialog.ShowDialog();

            if (!result.HasValue || (result.HasValue && !result.Value))
            {
                return;
            }
            if (!System.IO.File.Exists(saveDialog.FileName))
            {
                return;
            }
            //using (var streaem = new MemoryStream())
            using (var stream = new System.IO.StreamReader(saveDialog.OpenFile()))
            {
                var data       = Newtonsoft.Json.Linq.JObject.Parse(stream.ReadToEnd());
                var deployment = data.ToObject <Deployment>();
                if (deployment != null)
                {
                    DocumentManager.Open(deployment, saveDialog.SafeFileName);
                }
                else
                {
                    throw new Exception("potato");
                }
            }
        }
        private void LoadConfigExecute(object sender)
        {
            var fileDialog = new OpenFileDialog();

            fileDialog.Multiselect     = false;
            fileDialog.CheckFileExists = true;
            fileDialog.DefaultExt      = "*.msConfigStore";
            fileDialog.Filter          = "ConfigFile (*.msConfigStore)|*.msConfigStore";
            var result = fileDialog.ShowDialog();

            if (result.HasValue && result.Value && File.Exists(fileDialog.FileName))
            {
                Tables.Clear();
                Views.Clear();
                StoredProcs.Clear();
                SelectedTable = null;

                var         binFormatter = new BinaryFormatter();
                ConfigStore options;
                try
                {
                    using (var fs = fileDialog.OpenFile())
                    {
                        options = (ConfigStore)binFormatter.Deserialize(fs);
                    }
                }
                catch (Exception)
                {
                    Status = "File is an in invalid format";
                    return;
                }

                var version = typeof(SharedMethods).Assembly.GetName().Version;
                if (new Version(options.Version) != version)
                {
                    var messageBoxResult = MessageBox.Show(Application.Current.MainWindow,
                                                           "Warning Version missmatch",
                                                           string.Format("The current Entity Creator version ({0}) is not equals the version ({1}) you have provided.",
                                                                         version, options.Version),
                                                           MessageBoxButton.OKCancel);

                    if (messageBoxResult == MessageBoxResult.Cancel)
                    {
                        return;
                    }
                }

                if (options.SourceConnectionString != null)
                {
                    ConnectionString = options.SourceConnectionString;
                    CreateEntrysAsync(ConnectionString, "", string.Empty).ContinueWith(task =>
                    {
                        foreach (var optionsAction in options.Actions)
                        {
                            optionsAction.Replay(this);
                        }
                    });
                }
            }
        }
Пример #4
0
        /// <summary>
        /// The function to call when sending a picture
        /// </summary>
        /// <param name="cp">fill the packet with the appropriate information and write the image to the stream</param>
        public void SendPicture()
        {
            Microsoft.Win32.OpenFileDialog ofd;
            ofd                  = new Microsoft.Win32.OpenFileDialog();
            ofd.FileName         = "openFileDialog1";
            ofd.Filter           = "(*.JPG, *.GIF, *.PNG)|*.jpg;*.gif;*.png|All Files (*.*)|*.*";
            ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            ofd.RestoreDirectory = true;
            ofd.Title            = "Select a Picture";


            //check return value, but how in wpf?
            bool ok = (bool)ofd.ShowDialog();

            if (ok)
            {
                System.IO.Stream stream;
                if ((stream = ofd.OpenFile()) != null)
                {
                    PicturePacket packet = new PicturePacket();
                    packet.s        = stream;
                    packet.fileName = System.IO.Path.GetFileName(ofd.FileName);
                    MetadataFileInfo md = new MetadataFileInfo();
                    md.ReadMetaData(ofd.FileName);
                    packet.title          = md.Title;
                    packet.senderNodeName = mNodeName;
                    mOperationContract(packet);
                }
            }
        }
Пример #5
0
        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            var dlg = new Microsoft.Win32.OpenFileDialog
            {
                DefaultExt = ".jpg",
                Filter     =
                    "JPEG Files (*.jpeg)|*.jpeg|JPG Files (*.jpg)|*.jpg"
            };


            // Display OpenFileDialog by calling ShowDialog method
            var result = dlg.ShowDialog();

            if (result != true)
            {
                return;
            }
            var stream = dlg.OpenFile();

            using (stream)
            {
                var img = new Bitmap(stream);
                Model.Data     = Model.ImageToByteArray(img);
                Obrazok.Source = GetImageStream(new MemoryStream(Model.Data));
            }
        }
Пример #6
0
        private static Stream OpenDialog(string fileExt = ".fdw", string filter = "Free Draw Save (*.fdw)|*fdw")
        {
            var dialog = new Microsoft.Win32.OpenFileDialog()
            {
                DefaultExt = fileExt,
                Filter     = filter,
            };

            return(dialog.ShowDialog() == true?dialog.OpenFile() : Stream.Null);
        }
Пример #7
0
        Stream OpenFileRead()
        {
            var dialog = new Microsoft.Win32.OpenFileDialog();

            if (dialog.ShowDialog() == true)
            {
                return(dialog.OpenFile());
            }
            return(null);
        }
        private void openNetworksFileButton_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog();
            dialog.Filter      = "Neural Network Items|*.nni|Neural Networks|*.nn|All supported items|*.nni;*.nn";
            dialog.Multiselect = true;
            bool?result = dialog.ShowDialog(this);

            if (result == true)
            {
                networkFile = (FileStream)dialog.OpenFile();
            }
        }
Пример #9
0
        private void Load_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            //настройка параметров диалога
            dlg.DefaultExt = ".txt";                        // Default file extension
            dlg.Filter     = "Text documents (.txt)|*.txt"; // Filter files by extension
                                                            //вызов диалога
            dlg.ShowDialog();
            StreamReader file = new StreamReader(dlg.OpenFile());

            da = MyClass.Open(file);
        }
Пример #10
0
        public void loadFromROM( )
        {
            Byte[] theROM = new Byte[4096];
            UInt16 size   = 0;

            Microsoft.Win32.OpenFileDialog OpenRom = new Microsoft.Win32.OpenFileDialog();
            OpenRom.FileName   = "";
            OpenRom.DefaultExt = ".ch8";
            OpenRom.Filter     = "CHIP8 programs (.ch8)|*.ch8";

            Nullable <bool> result = OpenRom.ShowDialog();

            if (result == true)
            {
                try
                {
                    System.IO.FileStream Input;
                    if ((Input = (System.IO.FileStream)OpenRom.OpenFile()) != null)
                    {
                        using (Input)
                        {
                            System.IO.MemoryStream Piper = new System.IO.MemoryStream(theROM);
                            while (Input.CanRead)
                            {
                                String currentLine = Input.ReadByte().ToString();
                                if (currentLine.CompareTo("-1") == 0)//aha, still reads the EOF char
                                {
                                    break;
                                }
                                Piper.WriteByte(Byte.Parse(currentLine));
                                size++;
                            }
                            theROM = Piper.ToArray();
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
                //theROM to RAM
                int i = 0;
                while (i <= size)
                {
                    RAM[0x200 + i] = theROM[i];
                    i++;
                }
            }
            else
            {
                System.Windows.MessageBox.Show("Error: Could not open file.");
            }
        }
Пример #11
0
        Stream LoadFileCore()
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            if (dlg.ShowDialog() == true)
            {
#if !SL
                return(dlg.OpenFile());
#else
                return dlg.File.OpenRead()
#endif
            }
            return(null);
        }
Пример #12
0
 private void btn_Click(object sender, RoutedEventArgs e)
 {
     Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
     ofd.DefaultExt = ".jpg";
     ofd.Filter     = "JPG file|*.jpg";
     if (ofd.ShowDialog() == true)
     {
         Stream stream = ofd.OpenFile();
         PicByte = new byte[stream.Length];
         stream.Read(PicByte, 0, (int)stream.Length);
         txtPicPath.Text = ofd.FileName;
     }
 }
Пример #13
0
        private void Open_file_Click(object sender, RoutedEventArgs e)
        {
            //防止正在播放
            if (player != null)
            {
                player.stop();
            }

            //处理文件弹窗和文件名
            OpenFileDialog openFile = new OpenFileDialog();

            openFile.Filter = "音频文件|*.mp3";
            openFile.ShowDialog();
            char[]   sp = new [] { '\\' };
            String[] a  = openFile.FileName.Split(sp, 100);

            //定义输入流
            Stream input;

            //是否是未选择文件就关闭文件框的处理
            if (openFile.FileName.Length > 0)
            {
                input = openFile.OpenFile();
            }
            else
            {
                return;
            }

            //开始解码
            _pcmDatas.Clear();
            Decoder decoder = new Decoder(input, a[a.Length - 1], this, _pcmDatas);

            if (!decoder.Start())
            {
                //清空文件名文本框显示
                Filename.Text = null;
                MessageBox.Show("文件格式错误", "提示", MessageBoxButton.OK);
                _pcmDatas.Clear();
            }
            else
            {
                //设置文件名文本框显示
                Filename.Text = a[a.Length - 1];

                MessageBox.Show("解码成功,可以播放了", "提示", MessageBoxButton.OK);

                ChartViewThread chartView = new ChartViewThread(_pcmDatas, this);
                chartView.start();
            };
        }
Пример #14
0
        void CommandOpen(object o, EventArgs e)
        {
            var dialog = new Microsoft.Win32.OpenFileDialog()
            {
                Title = "読み込むファイルを選択してください。", DefaultExt = ".jdx", Filter = "直書きデスクトップファイル(*.jdx)|*.jdx"
            };

            if (dialog.ShowDialog().Value)
            {
                using (var stream = dialog.OpenFile())
                {
                    InkCanvas.Strokes = new System.Windows.Ink.StrokeCollection(stream);
                }
            }
        }
Пример #15
0
        static System.Drawing.Image LoadImageCore()
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Filter = EditorLocalizer.GetString(EditorStringId.ImageEdit_OpenFileFilter);
            if (dlg.ShowDialog() == true)
            {
#if !SL
                Stream stream = dlg.OpenFile();
#else
                Stream stream = dlg.File.OpenRead()
#endif
                return(System.Drawing.Image.FromStream(stream));
            }
            return(null);
        }
Пример #16
0
        private void OpenFile(object sender, RoutedEventArgs e)
        {
            var dialog = new Microsoft.Win32.OpenFileDialog();

            dialog.Filter   = "Text file(*txt)|*.txt|Allfile(*.*)|*.*";
            dialog.FileName = "*.txt";
            if (dialog.ShowDialog() == true)
            {
                using (var stream = dialog.OpenFile())
                {
                    var range = new TextRange(RTBeditor.Document.ContentStart, RTBeditor.Document.ContentEnd);
                    range.Load(stream, DataFormats.Text);
                }
            }
        }
Пример #17
0
        //-----------------------------------------------------------------------------
        #region ** file

        void _btnOpen_Click(object sender, RoutedEventArgs e)
        {
            var dlg = new Microsoft.Win32.OpenFileDialog();

            dlg.Filter = "Excel Workbook (*.xlsx)|*.xlsx|"
                         + "Excel 97-2003 Workbook (*.xls)|*.xls|"
                         + "Comma Separated Values (*.csv)|*.csv|" +
                         "Text File (*.txt)|*.txt";
            if (dlg.ShowDialog().Value)
            {
                try
                {
                    using (var s = dlg.OpenFile())
                    {
                        var ext = System.IO.Path.GetExtension(dlg.SafeFileName).ToLower();

                        switch (ext)
                        {
                        case ".csv":
                            _flex.LoadCsv(s, dlg.SafeFileName.Split('.')[0], ",");
                            break;

                        case ".txt":
                            //Separator must be '\t'
                            _flex.LoadTxt(s, dlg.SafeFileName.Split('.')[0]);
                            break;

                        case ".xlsx":
                            _flex.LoadExcel(s, C1.WPF.Excel.FileFormat.OpenXml);
                            break;

                        case ".xls":
                            _flex.LoadExcel(s, C1.WPF.Excel.FileFormat.Biff8);
                            break;

                        default:

                            break;
                        }
                    }
                }
                catch (Exception x)
                {
                    var msg = "Error opening file: \r\n\r\n" + x.Message;
                    MessageBox.Show(msg, "Error", MessageBoxButton.OK);
                }
            }
        }
        private void browseImageButton_Click(object sender, RoutedEventArgs e)
        {
            var openFileDialog = new Microsoft.Win32.OpenFileDialog();

            openFileDialog.Filter = "图片文件 (*.jpg;*.png;*.bmp)|*.jpg;*.png;*.bmp|全部文件 (*.*)|*.*";
            var dialogResult = openFileDialog.ShowDialog();

            if (dialogResult != true)
            {
                return;
            }
            var stream = openFileDialog.OpenFile();
            var bitmap = stream.ConvertToDecodeBitmap();

            this.imageView.ImageSource = bitmap;
        }
Пример #19
0
        public void LoadLevel()
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName   = "";                     // Default file name
            dlg.DefaultExt = ".dmk";                 // Default file extension
            dlg.Filter     = "Danmaku (.dmk)|*.dmk"; // Filter files by extension

            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                // Open document
                string       filename = dlg.FileName;
                StreamReader reader   = new StreamReader(dlg.OpenFile());
                ParseLevel(reader.ReadToEnd());
            }
        }
Пример #20
0
        protected override void OnClick()
        {
            Stream checkStream = null;

            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.Multiselect = false;
            if (mTransit != null)
            {
                openFileDialog.InitialDirectory = mTransit.DuongDanHinh;
            }
            else
            {
                openFileDialog.InitialDirectory = "c:\\";
            }

            openFileDialog.Filter = "All Image Files | *.*";
            if ((bool)openFileDialog.ShowDialog())
            {
                if ((checkStream = openFileDialog.OpenFile()) != null)
                {
                    Stream      fs           = File.OpenRead(openFileDialog.FileName);
                    BitmapImage mBitmapImage = new BitmapImage();
                    mBitmapImage.BeginInit();
                    mBitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                    mBitmapImage.StreamSource = fs;
                    mBitmapImage.EndInit();
                    //this.ImageBitmap = Utilities.ImageHandler.BitmapImageCopy(mBitmapImage);
                    //this.ImageBitmap = Utilities.ImageHandler.ImageToByte(mBitmapImage);
                    System.IO.FileInfo file = new FileInfo(openFileDialog.FileName);
                    if (mTransit != null)
                    {
                        mTransit.DuongDanHinh = file.Directory.FullName;
                    }
                    ;
                    this.Image       = mBitmapImage;
                    this.ImageBitmap = mBitmapImage;

                    if (_OnBitmapImageChanged != null)
                    {
                        _OnBitmapImageChanged(this);
                    }
                }
            }
            base.OnClick();
        }
        public async Task <string> LoadFromFile(string proposedFilename, string proposedExtension)
        {
            var openFileDialog = new Microsoft.Win32.OpenFileDialog {
                FileName   = proposedFilename,
                DefaultExt = proposedExtension
            };
            bool?result = openFileDialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                using (Stream stream = openFileDialog.OpenFile())
                    using (var reader = new StreamReader(stream))
                    {
                        return(await reader.ReadToEndAsync());
                    }
            }
            return(string.Empty);
        }
Пример #22
0
        private void save_Click(object sender, RoutedEventArgs e)
        {
            string filePath = "C:\\Record\\" + Window1._UserInfo.Id + ".avi";

            Microsoft.Win32.OpenFileDialog open = new Microsoft.Win32.OpenFileDialog();

            open.Multiselect = false;
            open.FileName    = filePath;
            open.Filter      = "AVI Files (*.avi)|*.avi";

            if ((bool)open.ShowDialog())
            {
                if (filePath == open.FileName)
                {
                    Uploader(open.FileName, open.OpenFile());
                }
            }
        }
Пример #23
0
        /// <summary>
        /// Метод для обработки события нажания на кнопку "Отправить файл".
        /// </summary>
        /// <param name="sender"> объект, инициировавший событие </param>
        /// <param name="e"> аргумент, хранящий информацию о событии </param>
        private void ButtonClickSendFile(object sender, RoutedEventArgs e)
        {
            if (ClientData.client != null && ClientData.CurrentUser.CurrentChatID != -1)
            {
                if (!ClientData.database.GetChatFromList(ClientData.CurrentUser.CurrentChatID).IsUserInChatSilent(ClientData.CurrentUser.ID))
                {
                    Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

                    Nullable <bool> result = dlg.ShowDialog();
                    if (result == true)
                    {
                        string filename = dlg.FileName;
                    }
                    else
                    {
                        return;
                    }

                    System.IO.StreamReader streamReader;
                    IrisLib.File           file = new IrisLib.File();

                    streamReader = new System.IO.StreamReader(dlg.FileName);
                    FileStream stream = (FileStream)dlg.OpenFile();
                    using (var memoryStream = new MemoryStream())
                    {
                        stream.CopyTo(memoryStream);
                        file.Binary = memoryStream.ToArray();
                        file.Name   = dlg.FileName.Split(new char[] { '\\' })[dlg.FileName.Split(new char[] { '\\' }).Length - 1];
                    }

                    if (ClientData.database.GetFilesFromDB(ClientData.CurrentUser.CurrentChatID).Contains(file.Name))
                    {
                        tbSavedFile.Text      = "Файл с таким именем уже существует";
                        lSavedFile.Visibility = Visibility.Visible;
                        return;
                    }

                    ButtonClickShowFiles(sender, e);
                    streamReader.Close();

                    ClientData.client.SendFileToHost(ClientData.CurrentUser, ClientData.CurrentUser.CurrentChatID, file);
                }
            }
        }
Пример #24
0
 private void uploadFile(object sender, RoutedEventArgs e)
 {
     try
     {
         var op = new Microsoft.Win32.OpenFileDialog();
         op.ShowDialog();
         var filestream = op.OpenFile();
         filestream.CopyTo(client.GetStream());
         formPrint(op.FileName + " Send.");
     }
     catch (ArgumentNullException err)
     {
         formPrint("ArgumentNullException", err);
     }
     catch (NullReferenceException)
     {
         formPrint("NullReferenceException");
     }
 }
Пример #25
0
        private void Button_Load_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog
            {
                DefaultExt = ".xml",
                Filter     = "Файлы записей|*.xml",
                FileName   = "Записи"
            };
            dlg.ShowDialog();

            using (var fileStream = dlg.OpenFile())
            {
                Reservation[] reservationsInFile = (Reservation[])serializer.Deserialize(fileStream);
                foreach (var reservation in reservationsInFile)
                {
                    reservations.Add(reservation);
                }
            }
        }
Пример #26
0
        private void buttonOpen_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openSaveFileDialog = new Microsoft.Win32.OpenFileDialog();
            XmlSerializer formatter = new XmlSerializer(typeof(DataBaseForStudents));
            Stream        myStream  = null;

            openSaveFileDialog.DefaultExt = ".xml";
            openSaveFileDialog.Filter     = "Студенты|*.xml";
            openSaveFileDialog.ShowDialog();
            myStream = openSaveFileDialog.OpenFile();
            DataBaseForStudents d2 = (DataBaseForStudents)formatter.Deserialize(myStream);

            textBox_FIO.Text         = d2.fio;
            textBox_Age.Text         = d2.age;
            comboBox_fak.Text        = d2.fak;
            comboBox_direction.Text  = d2.direction;
            textBox_course.Text      = Convert.ToString(d2.course);
            comboBox_expirience.Text = d2.expirience;
        }
Пример #27
0
        private void LoadFile()
        {
            Stream s;

            Microsoft.Win32.OpenFileDialog dlgLoad = new Microsoft.Win32.OpenFileDialog();

            dlgLoad.Filter           = "Infirmary Integrated simulation files (*.ii)|*.ii|All files (*.*)|*.*";
            dlgLoad.FilterIndex      = 1;
            dlgLoad.RestoreDirectory = true;

            if (dlgLoad.ShowDialog() == true)
            {
                if ((s = dlgLoad.OpenFile()) != null)
                {
                    LoadInit(s);
                    s.Close();
                }
            }
        }
Пример #28
0
        private void MenuItemImportTsv_OnClick(object sender, RoutedEventArgs e)
        {
            var dialog = new Microsoft.Win32.OpenFileDialog()
            {
                Title       = "Select TSV-formatted file to load",
                Filter      = "Supported files|*.tsv;*.txt",
                Multiselect = false
            };

            var result = dialog.ShowDialog();

            if (result != null && result.Value)
            {
                using (var stream = new StreamReader(dialog.OpenFile()))
                {
                    SetMap(TsvParser.Parse(stream));
                }
            }
        }
Пример #29
0
        public void LoadSong()
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName = ""; // Default file name
            //  dlg.DefaultExt = ".mp3"; // Default file extension
            //  dlg.Filter = "Mp3 |*.dmk"; // Filter files by extension
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                Mp3FileReader reader = new Mp3FileReader(dlg.OpenFile());
                SetLength((float)reader.TotalTime.TotalSeconds);
                string filename = dlg.FileName;
                // levelPlayer = Plugin.SimpleAudioPlayer.CrossSimpleAudioPlayer.Current;
                // levelPlayer.Load(dlg.OpenFile());

                // levelPlayer.Play();
            }
        }
Пример #30
0
        void dialog_FileOk(object sender, CancelEventArgs e)
        {
            try
            {
                using (Stream stream = dialog.OpenFile())
                {
                    MemoryStream ms = new MemoryStream();

                    System.Drawing.Image img = System.Drawing.Image.FromStream(stream);
                    ProfileImage = img;
                    img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

                    WebClient wc_uploader = new WebClient();
                    wc_uploader.UploadDataCompleted += new UploadDataCompletedEventHandler(wc_uploader_UploadDataCompleted);
                    wc_uploader.UploadDataAsync(new Uri(String.Format("https://blaze-games.com/api/uploadimage/?account={0}&password={1}", App.Account, App.Password)), ms.ToArray());
                }
            }
            catch { NotificationWindow.ShowNotification("Upload Failed", "Unable to upload your profile image since it was not a valid image file."); }
        }
Пример #31
0
        private void SelectScanButton_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName = "*.nessus";
            dlg.Filter   = "ACAS scan file (*.nessus)|*.nessus";

            if (dlg.ShowDialog() == true)
            {
                using (var filestream = dlg.OpenFile())
                {
                    using (var streamReader = new System.IO.StreamReader(filestream, Encoding.UTF8))
                    {
                        arequest.ACASXML = streamReader.ReadToEnd();
                    }
                }

                ACASFileName         = dlg.FileName;
                SaveButton.IsEnabled = true;
            }
        }
Пример #32
0
        private void LoadStructure_Menu_Click(object sender, RoutedEventArgs e)
        {
            Stream dicomfile = null;

            Microsoft.Win32.OpenFileDialog opendicom = new Microsoft.Win32.OpenFileDialog();
            opendicom.Multiselect = true;
            if (opendicom.ShowDialog() != false)
            {
                if (opendicom.FileNames.GetLength(0) > 1)
                {
                    string h = ""; string t = "";
                    foreach (string s in opendicom.FileNames)
                    {
                        System.IO.FileInfo f = new FileInfo(s);
                        if (f.Extension == ".h")
                            h = s;
                        if (f.Extension == ".txt")
                            t = s;
                    }
                    SS = new StructureSet(h, t);

                }
                else
                {
                    dicomfile = opendicom.OpenFile();
                    //TM = new DICOMRT(opendicom.FileName, 0);
                }

                if (SS.f_structurearray != null)
                {
                    slider2.Minimum = 0;
                    slider2.Maximum = SS.f_structurearray.GetLength(0);
                    tabControl1.SelectedIndex = 1;
                }
                AddStructureLoadedToListBox();
                Plan_btn.IsEnabled = true;
            }
        }
Пример #33
0
        private void btnimage_Click(object sender, RoutedEventArgs e)
        {
            Stream checkStream = null;
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();

            openFileDialog.Multiselect = false;
            openFileDialog.Filter = "Images |*.jpg;*.png;*.gif";
             try
                {
                    if ((bool)openFileDialog.ShowDialog())
                    {

                        if ((checkStream = openFileDialog.OpenFile()) != null)
                        {
                            image1.Source = new BitmapImage(new Uri(openFileDialog.FileName, UriKind.Absolute));
                            url = openFileDialog.FileName;
                        }
                    }
                    else
                    {
                        Show("Problem occured, try again later", 2);
                    }
                }
                catch (Exception ex)
                {
                    Show("Error: Could not read file from disk. Original error: " + ex.Message,2);
                }
        }
Пример #34
0
        public string SelectGameFile(out byte[] filedata)
        {
            String fName = null;
            byte[] buffer = null;
            Dispatcher.Invoke(new Action(delegate
            {
                Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
                ofd.Title = "Open a Z-Code file";
                ofd.DefaultExt = ".dat";

                ofd.Filter = CreateFilterList(
                 "Most IF Files (*.zblorb;*.dat;*.z?;*.blorb)|*.zblorb;*.dat;*.z?;*.blorb",
                 "Infocom Blorb File (*.zblorb)|*.zblorb",
                 "Infocom Games (*.dat)|*.dat",
                 "Z-Code Files (*.z?)|*.z?",
                 "Blorb File (*.blorb)|*.blorb");

                if (ofd.ShowDialog(_parent) == true)
                {
                    fName = ofd.FileName;
                    var s = ofd.OpenFile();
                    buffer = new byte[s.Length];
                    s.Read(buffer, 0, buffer.Length);
                    s.Close();
                }

            }));
            filedata = buffer;
            return fName;
        }
Пример #35
0
        protected override void OnClick()
        {
            Stream checkStream = null;
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
            openFileDialog.Multiselect = false;
            if (mTransit != null)
                openFileDialog.InitialDirectory = mTransit.DuongDanHinh;
            else
                openFileDialog.InitialDirectory = "c:\\";

            openFileDialog.Filter = "All Image Files | *.*";
            if ((bool)openFileDialog.ShowDialog())
            {
                if ((checkStream = openFileDialog.OpenFile()) != null)
                {

                    Stream fs = File.OpenRead(openFileDialog.FileName);
                    BitmapImage mBitmapImage = new BitmapImage();
                    mBitmapImage.BeginInit();
                    mBitmapImage.CacheOption = BitmapCacheOption.OnLoad;
                    mBitmapImage.StreamSource = fs;
                    mBitmapImage.EndInit();
                    //this.ImageBitmap = Utilities.ImageHandler.BitmapImageCopy(mBitmapImage);                    
                    //this.ImageBitmap = Utilities.ImageHandler.ImageToByte(mBitmapImage);
                    System.IO.FileInfo file = new FileInfo(openFileDialog.FileName);
                    if (mTransit != null)
                        mTransit.DuongDanHinh = file.Directory.FullName; ;
                    this.Image = mBitmapImage;
                    this.ImageBitmap = mBitmapImage;

                    if (_OnBitmapImageChanged != null)
                    {
                        _OnBitmapImageChanged(this);
                    }
                }
            }
            base.OnClick();
        }
        private void bOpenFileDialog_Click(object sender, RoutedEventArgs e)
        {
            Stream checkStream = null;
            Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();

            openFileDialog.Multiselect = false;
            //openFileDialog.InitialDirectory = "c:\\";
            //if you want filter only .txt file
            //dlg.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            //if you want filter all files
            openFileDialog.Filter = "All Files | *.*";
            if ((bool)openFileDialog.ShowDialog())
            {
                try
                {
                    if ((checkStream = openFileDialog.OpenFile()) != null)
                    {
                        //MyImage.Source = new BitmapImage(new Uri(openFileDialog.FileName, UriKind.Absolute));
                        filePath.Text = openFileDialog.FileName;
                        filePathString = openFileDialog.FileName;

                    }
                }
                catch (Exception ex)
                {
                   System.Windows.MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
            else
            {
                   System.Windows.MessageBox.Show("Problem occured, try again later");
            }
        }
Пример #37
0
            public void Execute(object parameter)
            {
                Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
                ofd.CheckFileExists = true;
                ofd.CheckPathExists = true;
                ofd.ValidateNames = true;
                ofd.Multiselect = false;
                if (ofd.ShowDialog() != true) return;

                using (System.IO.Stream s = ofd.OpenFile()) {
                    List<Models.Data.Xml.XmlSerializableDictionary<int, ProxyRule>.LocalKeyValuePair> list = new List<Models.Data.Xml.XmlSerializableDictionary<int, ProxyRule>.LocalKeyValuePair>();
                    System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(list.GetType());
                    list = (List<Models.Data.Xml.XmlSerializableDictionary<int, ProxyRule>.LocalKeyValuePair>)xs.Deserialize(s);

                    var rules = Settings.Current.ProxySettings.Rules;
                    list.ForEach(kv => rules[kv.Key] = kv.Value);

                    ((IProxySettings)Settings.Current.ProxySettings).CompiledRules = null;
                    vm.RaisePropertyChanged(nameof(vm.Rules));
                }
            }
        private void BtnSelectEmailsClick(object sender, RoutedEventArgs e)
        {
            // Create OpenFileDialog 
            var dlg = new Microsoft.Win32.OpenFileDialog {DefaultExt = ".txt", Filter = "Text documents (.txt)|*.txt"};

            // Display OpenFileDialog by calling ShowDialog method 
            var result = dlg.ShowDialog();

            // Get the selected file name and display in a TextBox 
            if (result != true) return;

            // Open document 
            var allEmailsStream = dlg.OpenFile();

            using (var reader = new System.IO.StreamReader(allEmailsStream))
            {
                while (!reader.EndOfStream)
                {
                    var email = reader.ReadLine();
                    if (!string.IsNullOrEmpty(email) && !_eMails.ContainsKey(email))
                    {
                        _eMails.Add(email, false);
                    }
                }
            }

            allEmailsStream.Close();
        }
Пример #39
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog temp = new Microsoft.Win32.OpenFileDialog();
            Stream myStream = null;

            List<Tuple<string, int>> resultat = new List<Tuple<string, int>>();

            temp.Filter = "CSV files (*.csv)|*.csv";
            Nullable<bool> result = temp.ShowDialog();
            if (result == true)
            {
                try
                {
                    if ((myStream = temp.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            StreamReader sr = new StreamReader(myStream);
                            String s = sr.ReadLine();
                            String[] temps;
                            while (s != null)
                            {
                                temps = s.Split(';');
                                resultat.Add(new Tuple<string, int>(temps[0], int.Parse(temps[1])));
                                s = sr.ReadLine();
                            }
                            sr.Close();
                        }
                    }
                    myStream.Close();

                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message + "\n" + ex.TargetSite + "\n" + ex.StackTrace + "\n" + ex.HelpLink);
                }
                worker.RunWorkerAsync(resultat);
            }
        }
Пример #40
0
        private void OnImportMenuItemClick( object sender, RoutedEventArgs e )
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();

            dlg.Title = "Import Configuration";

            AssignCommonFileDialogProps( dlg );

            if( dlg.ShowDialog() != true ) return;

            try
            {
                _windowData.Document.Load( dlg.OpenFile(), WidgetDocSaveFormat.Xml );

                widgetContainer.Source = _windowData.Document.Root;

                _windowResizer.SizeParentToContent();
            }
            catch( Exception ex )
            {
                ReportToUserApplicationError( ex, "There were issues importing configuration." );
            }
        }
Пример #41
0
 void _btnOpen_Click(object sender, RoutedEventArgs e)
 {
     var dlg = new Microsoft.Win32.OpenFileDialog();
     dlg.Filter = "Excel Workbook (*.xlsx)|*.xlsx";
     if (dlg.ShowDialog().Value)
     {
         try
         {
             using (var s = dlg.OpenFile())
             {
                 _flex.Load(s);
             }
         }
         catch (Exception x)
         {
             var msg = "Error opening file: \r\n\r\n" + x.Message;
             MessageBox.Show(msg, "Error", MessageBoxButton.OK);
         }
     }
 }
		private void LoadConfigExecute(object sender)
		{
			var fileDialog = new OpenFileDialog();
			fileDialog.Multiselect = false;
			fileDialog.CheckFileExists = true;
			fileDialog.DefaultExt = "*.msConfigStore";
			fileDialog.Filter = "ConfigFile (*.msConfigStore)|*.msConfigStore";
			var result = fileDialog.ShowDialog();
			if (result.HasValue && result.Value == true && File.Exists(fileDialog.FileName))
			{
				this.Tables.Clear();
				this.Views.Clear();
				this.StoredProcs.Clear();

				var binFormatter = new BinaryFormatter();
				ConfigStore options;
				try
				{
					using (var fs = fileDialog.OpenFile())
					{
						options = (ConfigStore)binFormatter.Deserialize(fs);
					}
				}
				catch (Exception)
				{
					Status = "File is an in invalid format";
					return;
				}

				var version = typeof(SharedMethods).Assembly.GetName().Version;
				if (new Version(options.Version) != version)
				{
					var messageBoxResult = MessageBox.Show(App.Current.MainWindow,
						"Warning Version missmatch",
						string.Format("The current Entity Creator version ({0}) is not equals the version ({1}) you have provided.",
							version, options.Version),
						MessageBoxButton.OKCancel);

					if(messageBoxResult == MessageBoxResult.Cancel)
						return;
				}

				foreach (var option in options.Tables)
				{
					var itemExisits = this.Tables.FirstOrDefault(s => s.Info.TableName == option.Info.TableName);
					if (itemExisits != null)
					{
						this.Tables.Remove(itemExisits);
					}

					this.Tables.Add(new TableInfoViewModel(option, this));
				}
				foreach (var option in options.Views)
				{
					this.Views.Add(new TableInfoViewModel(option, this));
				}
				foreach (var option in options.StoredPrcInfoModels)
				{
					this.StoredProcs.Add(option);
				}

				if (options.SourceConnectionString != null)
				{
					this.ConnectionString = options.SourceConnectionString;
					this.CreateEntrys(this.ConnectionString, "", string.Empty);
				}

				this.GenerateConstructor = options.GenerateConstructor;
				this.GenerateForgeinKeyDeclarations = options.GenerateForgeinKeyDeclarations;
				this.GenerateCompilerHeader = options.GenerateCompilerHeader;
				this.GenerateConfigMethod = options.GenerateConfigMethod;
				this.Namespace = options.Namespace;
				this.TargetDir = options.TargetDir;
				this.SelectedTable = Tables.FirstOrDefault();
			}
		}
Пример #43
0
        private void importPB_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog o = new Microsoft.Win32.OpenFileDialog();
            if (o.ShowDialog()==true)
            {
                System.IO.Stream myStream = o.OpenFile();
                byte[] bt = new byte[myStream.Length];
                myStream.Read(bt,0,(int)myStream.Length);

                var item = datagrid1.SelectedItem as EmployeeInfo;
                var q = from t in context.EmployeeInfo
                        where t.EmployeeNo == item.EmployeeNo
                        select t;
                try
                {
                    var q1 = q.FirstOrDefault();
                    if (q1!=null)
                    {
                        q1.photo = bt;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                   
                }
            }
        }
Пример #44
0
        private void LoadFileAction()
        {
            var dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.DefaultExt = ".c--";
            dlg.Filter = @"C-- programs (.c--)|*.c--|All files|*.*";

            if (dlg.ShowDialog() == true)
            {
                _lastUsedFileName = dlg.FileName;
                Title = TITLE + " " + Path.GetFileName(_lastUsedFileName);
                using (var reader = new StreamReader(dlg.OpenFile()))
                {
                    Code = new TextDocument(reader.ReadToEnd());
                }
            }
        }
Пример #45
0
        public static TeamViewModel OpenTeamWithFileDialog()
        {
            //hack: duplicated code don't have time to organize right now.
              Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
              dlg.InitialDirectory = Properties.Resources.InitialDirectory;
              dlg.Multiselect = false;
              var result = dlg.ShowDialog();
              if (result == null || result == false)
            return null;

              var stream = dlg.OpenFile();
              stream.Position = 0;

              var team = Team.LoadFromFile(stream);
              stream.Close();
              team.FileNameFullPath = dlg.FileName;
              team.Text = dlg.SafeFileName;

              var teamVM = Services.Container.GetExportedValue<TeamViewModel>();
              teamVM.Team = team;

              return teamVM;
        }
Пример #46
0
        private byte[] ObtenerBytex()
        {
            System.IO.Stream stream;
            Microsoft.Win32.OpenFileDialog openDialog = new Microsoft.Win32.OpenFileDialog();
            openDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            openDialog.Filter = "Pictures(*.jpg;*.jpeg;*.gif;*.png;*.bmp)|*.jpg;*.jpeg;*.gif;*.png;*.bmp| All Files (*.*)|*.*";
            openDialog.FilterIndex = 1;
            openDialog.Multiselect = false;
            byte[] imageData = null;

            if (openDialog.ShowDialog() == true)
            {
                try
                {
                    if ((stream = openDialog.OpenFile()) != null)
                    {
                        arcOri = openDialog.FileName;
                        ext = System.IO.Path.GetExtension(arcOri);
                        using (stream)
                        {
                            imageData = new byte[stream.Length];
                            stream.Read(imageData, 0, (int)stream.Length);
                        }
                        return imageData;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: No se puede subir la imagen " + ex.Message);
                    imageData = null;
                }
            }
            return imageData;
        }
Пример #47
0
        private void datRead()
        {
            Stream s = null;
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            Nullable<bool> result = dlg.ShowDialog();

            if (result == true)
            {
                string path = dlg.FileName;

                try
                {
                    if ((s = dlg.OpenFile()) != null)
                    {
                        using (BinaryReader reader = new BinaryReader(s))
                        {
                            Byte[] data = reader.ReadBytes((int)reader.BaseStream.Length);
                            sig1 = new ArrayList();
                            sig2 = new ArrayList();

                            for (int i = 0; i < data.Length - 2; i += 3)
                            {
                                sig1.Add(((data[i + 1] & 0x0F) << 8) | data[i]);
                                sig2.Add(((data[i + 1] >> 4) << 8) | data[i + 2]);
                            }
                        }
                        createPlot();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not read file from disk: " + ex.Message);
                }
            }
        }
Пример #48
0
        private void Import_Immob_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog temp = new Microsoft.Win32.OpenFileDialog();
            Stream myStream = null;

            List<Tuple<string,string, double>> immo = new List<Tuple<string,string, double>>();

            temp.Filter = "CSV files (*.csv)|*.csv";
            Nullable<bool> result = temp.ShowDialog();
            if (result == true)
            {
                try
                {
                    if ((myStream = temp.OpenFile()) != null)
                    {
                        using (myStream)
                        {
                            StreamReader sr = new StreamReader(myStream);
                            String s = sr.ReadLine();
                            String[] temps;
                            while (s != null)
                            {
                                temps = s.Split(';');
                                immo.Add(new Tuple<string,string, double>(temps[0],temps[1], double.Parse(temps[2])));
                                s = sr.ReadLine();
                            }
                            sr.Close();
                        }
                    }
                    myStream.Close();

                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message + "\n" + ex.TargetSite + "\n" + ex.StackTrace + "\n" + ex.HelpLink);
                }
            }
            Engine.getEngine().setImmo(immo);
            modulesTab.SelectedIndex = 1;
        }
Пример #49
0
        private void btnImagen_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                BitmapDecoder bitmap;
                Microsoft.Win32.OpenFileDialog directorio =
                    new Microsoft.Win32.OpenFileDialog();

                directorio.CheckFileExists = true;
                directorio.ValidateNames = true;
                directorio.Filter = "Imagenes png(*.png)|*png";

                if (directorio.ShowDialog() == true)
                {
                    using (Stream data = directorio.OpenFile())
                    {
                        bitmap = BitmapDecoder.Create(data,
                                BitmapCreateOptions.PreservePixelFormat,
                                BitmapCacheOption.OnLoad);
                        int width = bitmap.Frames[0].PixelWidth;
                        int height = bitmap.Frames[0].PixelHeight;

                        //if (width != 64 ||
                        //    height != 64)
                        //{
                        //    throw new Utilitario.ExepcionSHomies("Imagen debe ser de 64x64 pixeles");
                        //}
                        imgCategoria.Source = bitmap.Frames[0];
                        this.categoria.Imagen = Convert.ToBase64String(Funcion.ConvertStreamToBytes(directorio.OpenFile()));
                    }
                }
                else
                {
                    imgCategoria.Source = null;
                }
            }
            catch (Utilitario.ExepcionSHomies es)
            {
                MessageBox.Show(es.Message);
            }
            catch (Exception)
            {
                throw;
            }
        }
 private void Insert()
 {
     if (FileNameBox.Text != "")
     {
         Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
         ofd.FileName = FilePathBox.Text;
         try
         {
             Documents D = new Documents(FileNameBox.Text);
             D.SetData(ofd.OpenFile());
             if (D.Insert(Auth))
             {
                 statusText.Content = "上传成功!";
                 Reflush();
             }
             else
             {
                 statusText.Content = "上传失败!已存在内容相同的文件。";
                 Reflush();
             }
             return;
         }
         catch (System.IO.IOException ex)
         {
             Debuger.PrintException(ex);
             statusText.Content = ex.Message;
             return;
         }
     }
     statusText.Content = "请输入有效的文件名";
 }
Пример #51
0
        public void LoadFile()
        {
            Stream myStream = null;
            Int16 val;
            UInt32 time_offset;
            //Int16[] channel = new Int16[NUM_CHANNELS];
            Double time_calc;
            int pos = 0;
            string packet_display = "";

            Int32 buffer_loc = 0;

            Double SampleCount = 0;

            // Show the dialog and get result.
            Microsoft.Win32.OpenFileDialog openFileDialog1 = new Microsoft.Win32.OpenFileDialog();

            bool? result = openFileDialog1.ShowDialog();
            if (result == true) // Test result.
            {
                if ((myStream = openFileDialog1.OpenFile()) != null)
                {

                    foreach (GraphingData data in GraphData)
                    {
                        data.Channel_AllData.Collection.Clear();
                    }

                    //textBox1.AppendText(openFileDialog1.FileName + " Opened Successfully! File Size: " + myStream.Length + "\r\n"); // <-- For debugging use only.
                    //myStream.Length
                    byte[] buffer = new byte[myStream.Length];
                    // buffer_loc += 32 * NUM_PACKETS;
                    while (buffer_loc < myStream.Length)
                    {
                        //myStream.Read(buffer,
                        myStream.Read(buffer, 0, NUM_PACKETS);
                        byte[] packet = new byte[32];

                        while (pos < NUM_PACKETS)
                        {
                            // packet_display = "";
                            Array.Copy(buffer, pos, packet, 0, 32);
                            /*for (int i = 0; i < 32; i++)
                            {
                                packet[i] = buffer[i + pos];

                                //textBox1.AppendText(packet[i].ToString("X") + " ");
                                //packet_display += packet[i].ToString("X") + " ";

                            }*/

                            val = BitConverter.ToInt16(packet, 0);
                            time_offset = BitConverter.ToUInt32(packet, 2);
                            time_calc = time_offset * .00000002;

                            if (SampleCount == 0)
                            {
                                time_from_start = time_calc;
                                prev_time_calc = time_calc;
                            }
                            else if (time_calc < prev_time_calc)
                            {
                                time_from_start += (4294967296 * .00000002 - prev_time_calc) + time_calc;
                                prev_time_calc = time_calc;
                            }
                            else
                            {
                                time_from_start += time_calc - prev_time_calc;
                                prev_time_calc = time_calc;
                            }

                            //textBox1.AppendText("\r\n\r\nTimeOffset: " + time_calc.ToString("00.000000"));
                            // packet_display += "\r\nTimeOffset: " + time_calc.ToString("00.000000");

                            for (int i = 0; i < ChannelsToGraph; i++)
                            {
                                Int16 raw_voltage = BitConverter.ToInt16(packet, 7 + i * 3);
                                //textBox1.AppendText("\tChannel" + i.ToString() + ": " + (channel[i] / 32768.0 * 5.0).ToString("0.000") + "V\t");
                                // packet_display += "\tChannel" + i.ToString() + ": " + (channel[i] / 32768.0 * 5.0).ToString("0.000") + "V\t";
                                if (raw_voltage == 0) { raw_voltage = 1; }
                                Point p1 = new Point(time_from_start, raw_voltage / 32768.0 * 10.0);
                                GraphData[i].Channel_AllData.Collection.Add(p1);
                            }
                            //textBox1.AppendText(packet_display + "\r\n\r\n");

                            //Point p1 = new Point(time_from_start, channel[0] / 32768.0 * 5.0);
                            //Point p1 = new Point(SampleCount, channel[0] / 32768.0 * 5.0);
                            //Point p1 = new Point(SampleCount, SampleCount);
                            //Channel1_Data.AppendAsync(Dispatcher, p1);
                            //Channel1_Data.Channel_AllData.Collection.Add(p1);
                            //Channel1_Data.Collection.Add(p1);
                            // Thread.Sleep(5);

                            pos += 32;
                            SampleCount++;

                            //plotter.Viewport.FitToView();
                        }
                        buffer_loc += NUM_PACKETS;
                        pos = 0;
                        if (buffer_loc > myStream.Length)
                        {
                        }
                    }

                }
                myStream.Close();
                //System.Text.Encoding.
                /*foreach (Channels temp in Graph_DataGrid.SelectedItems)
                {
                    string channel_name = temp.channel;
                    string[] split = channel_name.Split(' ');
                    int index = Convert.ToInt16(split[1]) - 1;

                    Point[] AllPoints = GraphData[index].Channel_AllData.Collection.ToArray();
                    Point[] GraphPoints = new Point[NUM_SAMPLES_DISPLAYED];
                    Array.Copy(AllPoints, AllPoints.Length - NUM_SAMPLES_DISPLAYED, GraphPoints, 0, NUM_SAMPLES_DISPLAYED);

                    GraphData[index].Channel_GraphData.Collection.AddMany(GraphPoints);
                }*/
                //plotter.Children.RemoveAll<LineGraph>();

                //foreach (GraphingData data in GraphData)
                //{
                //    plotter.AddLineGraph(data.Channel_GraphData);
                //data.SetAllPointArray();

                // }
                //Graph_DataGrid.SelectedIndex = 0;

                //chan1Points = Channel1_Data.Channel_AllData.Collection.ToArray();

                // Point[] points = new Point[NUM_SAMPLES_DISPLAYED];
                //Array.Copy(chan1Points, chan1Points.Length - NUM_SAMPLES_DISPLAYED, points, 0, NUM_SAMPLES_DISPLAYED);

                // Channel1_Data.Channel_GraphData.Collection.AddMany(points);
                //plotter.AddLineGraph(Channel1_Data.Channel_GraphData, 2, "Data row 1");
                //plotter.AddLineGraph(Channel1_Data, 2, "Data row 1");
            }
        }
Пример #52
-26
        private void MenuItem_Open_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog();
            ofd.DefaultExt = ".hex";
            ofd.Filter = "HEX Files (*.hex)|*.hex|All Files (*.*)|*.*";
            Nullable<bool> selected = ofd.ShowDialog();

            if(selected==true)
            {
                //lstISA.Items.Clear();
                lstHex.Items.Clear();
                string fname = ofd.FileName;
                StreamReader sr = new StreamReader(ofd.OpenFile());
                while(!sr.EndOfStream)
                    lstHex.Items.Add(sr.ReadLine());
                pic = new PIC(fname);
                ISA = pic.decompile();
                lstISA.ItemsSource = ISA;
                //foreach (var x in ISA)
                //{
                //    lstISA.Items.Add(x);
                //}
                mnuRun.IsEnabled = true;
                CLK.Interval = pic.getclkInterval()/2;
                CLK.Elapsed += CLK_Elapsed;
                CLK.AutoReset = true;
                lblStatus.DataContext = pic.getCurrent();
            }
        }