Пример #1
0
        private void OnClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Multiselect = true;
            if (dlg.ShowDialog() == true)
            {
                if (MessageBox.Show("Are you sure you want to upload the selected files?", "Confirm Upload", MessageBoxButton.OK) == MessageBoxResult.OK)
                {

                    //string cmd = "test";
                    //string msg = "test";

                    //string url = "https://secure.veshter.com/static/bulkupload/test/dummyack.php";
                    string url = "http://localhost:7777/BulkUploaderTestPage.html";

                    VESHTER.HttpHelper helper = new VESHTER.HttpHelper(url);//, "POST",
            //new KeyValuePair<string, string>("authKey", "key"),
            //new KeyValuePair<string, string>("cmd", cmd.ToString()),
            //new KeyValuePair<string, string>("msg", msg));
                    //helper.ResponseComplete += new VESHTER.HttpResponseCompleteEventHandler(this.CommandComplete);
                    //helper.Execute();

                    //foreach (System.IO.FileInfo info in dlg.Files)
                    //{
                    //    post.Post();
                    //}

                }
            }
        }
Пример #2
0
 private void BtnBrowseImage_Click(object sender, RoutedEventArgs e)
 {
     OpenFileDialog ofd = new OpenFileDialog
     {
         Multiselect = false, //Filter = "Jpeg Files (*.jpg)|*.jpg|All Files(*.*)|*.*",
         Filter = "JPEG Images (*.jpeg *.jpg)|*.jpeg;*.jpg|Png Images (*.png)|*.png",
     };
     if (ofd.ShowDialog() == true)
     {
         try
         {
             LoadingInfo.Visibility = System.Windows.Visibility.Visible;
             focusRectangle.Viewport.Visibility = System.Windows.Visibility.Collapsed;
             focusRectangle.LoadImageStream(ofd.File.OpenRead(), ZoomInOut);
             fileInfo = ofd.File;
             BtnUploadImage.IsEnabled = BtnAdvanceMode.IsEnabled = false;
             ZoomInOut.IsEnabled = true;
             System.Threading.Timer timer = new System.Threading.Timer(TimerCallback,
                  new LoadingState()
                  {
                      focusRectangle = focusRectangle,
                      LoadingInfo = LoadingInfo,
                      BtnUploadImage = BtnUploadImage,
                      BtnAdvanceMode = BtnAdvanceMode
                  } as object,
                  1000, 500);   
         }
         catch (Exception exception)
         {
             Utils.ShowMessageBox("文件无效:" + exception.Message);
             ZoomInOut.IsEnabled = false;
             BtnUploadImage.IsEnabled = BtnAdvanceMode.IsEnabled = false;
         }
     }
 }
Пример #3
0
        private void btnFile2_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var dialog = new OpenFileDialog { Multiselect = false };
                if (dialog.ShowDialog() == true)
                {
                    using (var stream = dialog.File.OpenRead())
                    {
                        StreamReader sr = new StreamReader(stream, new Gb2312Encoding());
                        strDst = sr.ReadToEnd();

                        // 删除多余的换行
                        strDst = strDst.Replace("\0", "");

                        if (!string.IsNullOrEmpty(strDst))
                            CompareFile();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 public SilverlightLoadModelDialog()
 {
     _loadFileDialog = new OpenFileDialog
     {
         Filter = "Turtle Pictures (.tur)|*.tur",
     };
 }
Пример #5
0
 private void View_SetFocus(object sender, EventArgs e)
 {
     try
     {
         if (sender is int)
         {
             switch (Convert.ToInt32(sender))
             {
                 case 0:
                     OpenFileDialog op = new OpenFileDialog();
                     op.Filter = "Excel xml (*.xml)|*.xml";
                     if (op.ShowDialog() == true)
                     {
                         if (this.DataContext is UploadSubjectViewModel)
                         {
                             (this.DataContext as UploadSubjectViewModel).OnGetFileClickComplete(op.File);
                         }
                     }
                     break;
             }
         }
         if (sender is List<CustomizeSubjectType>)
         {
             Telerik.Windows.Controls.GridViewComboBoxColumn col = rgvData.Columns["type"] as Telerik.Windows.Controls.GridViewComboBoxColumn;
             if (col != null)
             {
                 col.ItemsSource = sender as List<CustomizeSubjectType>;
             }
         }
     }
     catch (Exception ex)
     {
         MessageCustomize.Show(ex.Message);
     }
 }
Пример #6
0
        private async void Browse()
        {
            var dlg = new OpenFileDialog
            {
                Multiselect = false,
                Filter = "JPEG Images (*.jpg, *.jpeg)|*.jpg;*.jpeg"
            };

            if (dlg.ShowDialog() == true)
            {
                var file = dlg.File;

                var progress = new ProgressWindow { Content = "Закачиваем файл..." };
                progress.Show();

                var task = await filesRepository.Create(file.OpenRead(), file.Name, "image/jpeg");

                if (task.Succeed)
                {
                    var fileId = task.Result;
                    var task2 = await productsRepository.AttachFile(productId, fileId);
                    if (task2.Succeed)
                    {
                        await LoadFiles();
                    }
                }

                progress.Close();
            }
        }
        private void btnOpenLog_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = "Log Files (.log)|*.log|All Files (*.*)|*.*";
            dlg.FilterIndex = 1;

            bool? userClickedOK = dlg.ShowDialog();

            // Process input if the user clicked OK.
            if (userClickedOK == true)
            {
                grdLog.ItemsSource = null;
                // Open the selected file to read.
                System.IO.Stream fileStream = dlg.File.OpenRead();
                using (System.IO.StreamReader reader = new System.IO.StreamReader(fileStream))
                {
                    try
                    {
                        Log.Instance.InitializeFromStream(reader);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("There was an error reading this log file. { " + ex.StackTrace + " }");
                    }
                }
                fileStream.Close();
                grdLog.ItemsSource = Log.Instance.Items;
            }
        }
Пример #8
0
        /// <summary>
        ///     选择文件对话框事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SelectFilesButton_Click(object sender, RoutedEventArgs e)
        {
            var ofd = new OpenFileDialog {Multiselect = true};

            try
            {
                if (!string.IsNullOrEmpty(_fileFilter))
                    ofd.Filter = _fileFilter;
            }
            catch (ArgumentException ex)
            {
                //User supplied a wrong configuration file
                throw new Exception("Wrong file filter configuration.", ex);
            }

            if (ofd.ShowDialog() != true) return;
            foreach (var file in ofd.Files)
            {
                var userFile = new UploadFile
                {
                    FileName = file.Name,
                    FileStream = file.OpenRead()
                };

                if (userFile.FileStream.Length <= _maxFileSize)
                {
                    //向文件列表中添加文件信息
                    _files.Add(userFile);
                }
                else
                {
                    MessageBox.Show( "Maximum file size is: " + (_maxFileSize/1024) + "KB.");
                }
            }
        }
        /// <summary>

        /// Browse button

        /// </summary>

        private void BrowseButton_Click(object sender, RoutedEventArgs e)
        {

            OpenFileDialog openFileDialog = new OpenFileDialog();

            // Limit the dialog to only show ".csv" files,

            // modify this as necessary to allow other file types

            openFileDialog.Filter = "xml (*.xml)|*.xml";

            openFileDialog.FilterIndex = 1;

            openFileDialog.Multiselect = true;
            documentStream = new List<FileStream>();
            if (openFileDialog.ShowDialog() == true)
            {

                foreach (FileInfo file in openFileDialog.Files)
                {
                    this.FileTextBox.Text += file.Name + ",";

                    System.IO.FileStream myStream = file.OpenRead();

                    documentStream.Add(myStream);
                }
                this.FileTextBox.IsReadOnly = true;

            }

        }
        public void PromptForParts(Action<IEnumerable<ComposablePartCatalog>> callback)
        {
            if (callback != null)
            {
                List<ComposablePartCatalog> catalogs = new List<ComposablePartCatalog>();

                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "XAPs (*.xap)|*.xap";
                dialog.Multiselect = false;

                if (dialog.ShowDialog() == true)
                {
                    var fileStream = dialog.File.OpenRead();

                    var assemblies = Package.LoadPackagedAssemblies(fileStream);

                    AggregateCatalog catalog = new AggregateCatalog();

                    CatalogHelper.DiscoverParts(catalog, assemblies);

                    catalogs.Add(catalog);
                }

                callback(catalogs);
            }
        }
Пример #11
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openDialog = new OpenFileDialog();
            openDialog.Filter = "JPEG / PNG (*.jpg;*.jpeg;*.png)|*.jpg;*.jpeg;*.png";
            if (openDialog.ShowDialog().GetValueOrDefault(false))
            {
                using (FileStream stream = openDialog.File.OpenRead())
                {
                    wb = ImageHelper.GetImageSource(stream, 700, 700);
                }

                //byte[] buffer;
                //using (
                    Stream Source = JpgEncoder.Encode(wb, 85); //)
                {
                    //int bufferSize = Convert.ToInt32(Source.Length);
                    //buffer = new byte[bufferSize];
                    //Source.Read(buffer, 0, bufferSize);

                    //Create a new UserFile object

                    _file.FileName = openDialog.File.Name;
                    _file.FileStream = Source;
                    //userFile.UIDispatcher = this.Dispatcher;
                    _file.UploadContainerUrl = _uploadContainerUrl;

                    _file.Upload(null);

                    //Source.Close();
                }
            }
        }
Пример #12
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog nekaj = new OpenFileDialog();

            bool? nekaj2 = nekaj.ShowDialog();
            if (nekaj2 == true)
            {

                using (FileStream fs = nekaj.File.OpenRead())
                {
                    byte[] buffer = new byte[(int)fs.Length];
                    fs.Read(buffer, 0, (int)fs.Length);
                    char[] niz = new char[buffer.Length];

                    for (int i = 0; i < buffer.Length; i++)
                        niz[i] = (char)buffer[i];

                    IsolatedStorageFile isf =
            IsolatedStorageFile.GetUserStoreForApplication();
                    IsolatedStorageFileStream tok = new IsolatedStorageFileStream("test.txt", FileMode.Create, isf);
                    tok.Write(buffer, 0, buffer.Length);

                    tok.Close();
                }
            }
            else MessageBox.Show("Preklicano");
        }
Пример #13
0
        private void OpenFile(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog()
            {
                Filter = "图片 (*.jpg)|*.jpg",
                Multiselect = false  //不允许多选
            };
            bool chooseFile = dialog.ShowDialog() == true;
            if (!chooseFile) { return; }
            cover.CanSee = true;

            Stream tStream = dialog.File.OpenRead();
            byte[] t = new byte[tStream.Length];
            tStream.Read(t, 0, (int)tStream.Length);
            PicServiceClient client = new PicServiceClient();
            client.UploadCompleted += (_sender, _e) =>
                {

                    State = _e.Result;
                    cover.CanSee = false;
                    hadOpenFile = true;
                };
            client.UploadAsync(t);

            Stream ts = new MemoryStream(t);
            BitmapImage bi = new BitmapImage();
            bi.SetSource(ts);
            img.ImageSource = bi;
        }
        private void UploadButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Filter = "XAP Files|*.xap";
            dialog.Multiselect = false;

            if (dialog.ShowDialog() == true && dialog.File != null)
            {
                FileStream fileStream = dialog.File.OpenRead();
                string selectedFileName = dialog.File.Name;
                if (selectedFileName.EndsWith(".xap", StringComparison.OrdinalIgnoreCase))
                    selectedFileName = selectedFileName.Substring(0, selectedFileName.Length - 4);
                if (BuilderApplication.Instance.AllExtensions.FirstOrDefault<Extension>(ex => string.Compare(ex.Name, selectedFileName, StringComparison.InvariantCultureIgnoreCase) == 0) != null)
                {
					MessageBoxDialog.Show(ESRI.ArcGIS.Mapping.Builder.Resources.Strings.ExtensionWithSameNameAlreadyExist, ESRI.ArcGIS.Mapping.Builder.Resources.Strings.ExtensionAlreadyExists, MessageBoxButton.OKCancel, (o, args) =>
                    {
                        if (args.Result == MessageBoxResult.OK)
                        {
                            validateXap(fileStream, onValidationComplete, dialog);
                        }
                        else
                        {
                            fileStream.Close();
                        }
                    });
                }
                else
                {
                    validateXap(fileStream, onValidationComplete, dialog);
                }              
            }
        }        
Пример #15
0
        public UserWindow()
        {
            InitializeComponent();
            _openDialog = new OpenFileDialog();

            Loaded += OnWindowsLoaded;
        }
        private void imgimagedata_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var imgcontrol = (sender as Image);
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "All Files (*.*)|*.*";
            ofd.FilterIndex = 1;
            if ((bool)ofd.ShowDialog())
            {
                ofd.FilterIndex = 1;
                using (FileStream stream = ofd.File.OpenRead())
                {
                    Byte[] bytes = new Byte[stream.Length];
                    stream.Read(bytes, 0, bytes.Length);
                    var base64encodedstr = Convert.ToBase64String(bytes);

                    //BitmapImage imgSrc = new BitmapImage();
                    //imgSrc.SetSource(stream);
                    //imgcontrol.Source = imgSrc;

                    imgcontrol.Source = SymbolEditor.Silverlight.Tasks.EncodeImage.Base64ToImage(base64encodedstr);
                    picturemarkersymbol.ImageData = base64encodedstr;
                     UpdateJson();
                }
            }
            else
            {
                //
            }
        }
Пример #17
0
		public override void Execute(object parameter)
		{
			var openFile = new OpenFileDialog
			{
				Filter = "csv|*.csv"
			};

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

			taskModel.TaskStatus = TaskStatus.Started;
			output(string.Format("Importing from {0}", openFile.File.Name));

			var streamReader = openFile.File.OpenText();

			var importImpl = new ImportImpl(streamReader, openFile.File.Name, taskModel, output, DatabaseCommands);
			importImpl.ImportAsync()
				.ContinueWith(task =>
				{
					importImpl.Dispose();
					return task;
				})
				.Unwrap()
				.Catch();
		}
Пример #18
0
 private void SelectFileButtonClick(object sender, System.Windows.RoutedEventArgs e)
 {
     var openFileDialog = new OpenFileDialog {Filter = "CSV Files|*.csv"};
     var userClickedOk = openFileDialog.ShowDialog();
     if (userClickedOk == true)
         ((ImportDataVM) this.DataContext).SelectFileCommand.Execute(openFileDialog.File);
 }
Пример #19
0
 public void UploadFile()
 {
     OpenFileDialog openFileDialog = new OpenFileDialog();
     openFileDialog.Filter = "All files|*.*";
     openFileDialog.Multiselect = false;
     if (openFileDialog.ShowDialog() == true)
     {
         try
         {
             using (FileStream strm = openFileDialog.File.OpenRead())
             {
                 selectedFile = openFileDialog.File;
                 using (BinaryReader rdr = new BinaryReader(strm))
                 {
                     fileBuffer = rdr.ReadBytes((int)strm.Length);
                 }
             }
             CreateFileUpload();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Пример #20
0
    private void BrowseAssembly(object sender, RoutedEventArgs e)
    {
      var dialog = new OpenFileDialog { Filter = "Assembly Files(*.exe, *.dll)|*.exe;*.dll" };
      if (dialog.ShowDialog() == false)
      {
        Definition = null;
        DialogResult = false;
        return;
      }

      Definition = AssemblyDefinition.ReadAssembly(dialog.File.OpenRead());
      if (Definition == null) Debugger.Break();

      if (Definition.FullName == _reference.FullName)
      {
        if (Definition.IsSilverlight())
          StorageService.CacheSilverlightAssembly(dialog.File.Name, dialog.File.OpenRead());
        else
          StorageService.CacheNetAssembly(dialog.File.Name, dialog.File.OpenRead());

        ApplicationModel.Current.AssemblyCache.AddAssembly(Definition);

        DialogResult = true;
      }
    }
Пример #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CertificateWindow"/> class.
        /// </summary>
        public CertificateWindow()
        {
            InitializeComponent();
            _openDialog = new OpenFileDialog();

            Loaded += OnWindowsLoaded;
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {

            Button btn = sender as Button;
            //OpenFile Dialog
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Multiselect = false;
            dlg.Filter = "All files|*.*";

            if ((bool)dlg.ShowDialog())
            {
                var bi1 = new BitmapImage();
                bi1.SetSource(dlg.File.OpenRead());

                PageService.PageSupport vmb = btn.DataContext as PageService.PageSupport;
                Stream s = dlg.File.OpenRead();
                byte[]filebytes = new byte[s.Length];

                s.Write(filebytes, 0, filebytes.Length);
  
                //Save to DB
                //vmb.image = 

                PageService.PageServiceClient psc = new PageService.PageServiceClient();
                psc.UpdatePageSupportByIDAsync(vmb);
                UploadFile(dlg.File.Name, dlg.File.OpenRead());
            }
            else //cancel
            {
                //StatusText.Text = "No file selected...";
            }
        }
Пример #23
0
        public IEnumerable<IResult> Open()
        {
            var dialog = new OpenFileDialog();
            yield return Show.OpenFileDialog(dialog);

            yield return Show.MessageBox("You opened " + dialog.File.Name + ".", "File");
        }
Пример #24
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                OpenFileDialog fd = new OpenFileDialog();
                fd.Multiselect = false;
                fd.Filter = "jpg 图片 (*.jpg)|*.jpg|png 图片 (*.png)|*.png";
                bool? fdIsShow = fd.ShowDialog();
                if (Convert.ToBoolean(fdIsShow))
                {
                    bmp = new BitmapImage();
                    FileStream fs = fd.File.OpenRead();
                    SourceImageByte = StreamToBytes(fs);
                    bmp.SetSource(fs);
                    fs.Close();

                    ImageBrush berriesBrush = new ImageBrush();
                    berriesBrush.ImageSource = bmp;
                    BHeart.Fill = berriesBrush;

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #25
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();
            dlg.Filter = GlobalMembers.SupportedFileType;
            dlg.FilterIndex = 1;
            dlg.Multiselect = false;

            if ((bool)dlg.ShowDialog())
            {
                foreach (UploadItem ui in listUploadItems.Items)
                {
                    if (ui.ItemInfo.Name == dlg.File.Name)
                        return;
                }

                int itemId = listUploadItems.Items.Count;
                if (itemId < GlobalMembers.MaxThread)
                {
                    UploadItem item = new UploadItem(dlg.File, itemId);
                    listUploadItems.Items.Add(item);

                    if (IsSignIn && !btnUpload.IsEnabled)
                        btnUpload.IsEnabled = true;
                }
            }
        }
Пример #26
0
        /// <summary>
        /// Event handler for the Button on the Page.
        /// </summary>
        /// <param name="sender">
        /// The button which was clicked.
        /// </param>
        /// <param name="e">
        /// The state when this event was generated.
        /// </param>
        private void OpenMedia(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.ShowDialog();

            Mp3MediaStreamSource mediaSource = new Mp3MediaStreamSource(ofd.File.OpenRead());
            me.SetSource(mediaSource);
        }
		public void ImportExcel()
		{
			OpenFileDialog dialog = new OpenFileDialog();
			if (dialog.ShowDialog() == true)
			{
				IoC.Get<IEventAggregator>().Publish(new InvoiceGeneratorMessage { File = dialog.File });
			}
		}
Пример #28
0
 private void UpdatePhoto()
 {
   var of = new OpenFileDialog();
   var showDialog = of.ShowDialog();
   if (showDialog != null && showDialog.Value)
   {
     string fileName = of.File.Name;
   }
 }
Пример #29
0
 private void btnImage_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     OpenFileDialog dlg = new OpenFileDialog();
     dlg.Filter = "Image Files (*.bmp, *.jpg, *.png)|*.bmp;*.jpg;*.png";
     if (dlg.ShowDialog() == true)
     {
         dataProvider.UploadData.Image = dlg.File;
     }
 }
Пример #30
0
 private void btnPoints_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     OpenFileDialog dlg = new OpenFileDialog();
     dlg.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
     if (dlg.ShowDialog() == true)
     {
         dataProvider.UploadData.Points = dlg.File;
     }
 }
Пример #31
0
        /// <summary>
        ///
        /// </summary>
        private void PerformImport(string _scope, GraphDataFormatBase format)
        {
            string importData = string.Empty;

            System.Windows.Controls.OpenFileDialog openFileDialog = new System.Windows.Controls.OpenFileDialog();

            openFileDialog.Filter      = string.Format("{0} (*.{1}) | *.{1}", format.Description, format.Extension);
            openFileDialog.FilterIndex = 1;
            openFileDialog.Multiselect = false;

            bool?dialogResult = openFileDialog.ShowDialog();

            if (dialogResult == true)
            {
                // Open the file and read it into our variable
                importData = openFileDialog.File.OpenText().ReadToEnd();

                //TODO:  ADD ERROR TRAPPING HERE
                if (!string.IsNullOrEmpty(importData))
                {
                    ImportData(importData, _scope, format);
                }
            }
        }