示例#1
0
 public static System.Windows.Forms.IWin32Window GetIWin32Window(this System.Windows.Media.Visual visual)
 {
     var source = System.Windows.PresentationSource.FromVisual(visual) as System.Windows.Interop.HwndSource;
     Debug.Assert(source != null, "source != null");
     System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle);
     return win;
 }
示例#2
0
        public static System.Windows.Forms.IWin32Window GetIWin32Window(this System.Windows.Media.Visual visual)
        {
            var source = System.Windows.PresentationSource.FromVisual(visual) as System.Windows.Interop.HwndSource;

            System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle);
            return(win);
        }
示例#3
0
        private void Browse_Click(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog dlg2 = new System.Windows.Forms.OpenFileDialog();
            dlg2.Title = "Choose Upload File Name";
            if (FormatCSV.IsChecked.Value)
            {
                dlg2.Filter   = "Comma-separated Value Files (*.csv)|*.csv|Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                dlg2.FileName = TableName.Text + ".csv";
            }
            else if (FormatPlainXML.IsChecked.Value)
            {
                dlg2.Filter   = "XML Files (*.xml)|*.xml|Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                dlg2.FileName = TableName.Text + ".xml";
            }
            else if (FormatAtomPub.IsChecked.Value)
            {
                dlg2.Filter   = "XML Files (*.xml)|*.xml|Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                dlg2.FileName = TableName.Text + ".xml";
            }

            HwndSource source = PresentationSource.FromVisual(MainWindow.Window) as HwndSource;

            System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle);

            System.Windows.Forms.DialogResult result = dlg2.ShowDialog(win);
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                FileName.Text = dlg2.FileName;
            }
        }
示例#4
0
        private void UploadTextFile_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
            dlg.Title            = "Upload Text File to Blob";
            dlg.InitialDirectory = TextDirectory;

            dlg.Filter = "Text Files (*.txt)|*.txt|CSV Files (*.csv)|*.csv|Data Files (*.dat)|*.dat|All Files (*.*)|*.*";
            HwndSource source = PresentationSource.FromVisual(MainWindow.Window) as HwndSource;

            System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle);

            System.Windows.Forms.DialogResult result = dlg.ShowDialog(win);
            if (result == System.Windows.Forms.DialogResult.OK)
            {
                Cursor = Cursors.Wait;

                try
                {
                    ViewModel.SaveTextFile(dlg.FileName);
                    MessageBox.Show("The blob has been updated", "Update Successful", MessageBoxButton.OK);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("The blob update failed due to an error.\r\n\r\n" + ex.ToString(),
                                    "Update Failed", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }

                Cursor = Cursors.Arrow;
            }
        }
        public static IWin32Window GetIWin32Window(this Visual visual)
        {
            var          source = PresentationSource.FromVisual(visual) as HwndSource;
            IWin32Window win    = new OldWindow(source.Handle);

            return(win);
        }
示例#6
0
        public static System.Windows.Forms.IWin32Window AsWin32Window(Window window)
        {
            var source = PresentationSource.FromVisual(window) as System.Windows.Interop.HwndSource;

            System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle);
            return(win);
        }
示例#7
0
 private void btnLogPathBrower_Click(object sender, RoutedEventArgs e)
 {
     System.Windows.Forms.FolderBrowserDialog dlg    = new System.Windows.Forms.FolderBrowserDialog();
     System.Windows.Interop.HwndSource        source = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource;
     System.Windows.Forms.IWin32Window        win    = new OldWindow(source.Handle);
     System.Windows.Forms.DialogResult        result = dlg.ShowDialog(win);
     txtLOGLocation.Text = dlg.SelectedPath;
 }
示例#8
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            System.Windows.Forms.FolderBrowserDialog folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
            HwndSource   source = PresentationSource.FromVisual(this) as HwndSource;
            IWin32Window win    = new OldWindow(source.Handle);

            System.Windows.Forms.DialogResult result = folderBrowserDialog.ShowDialog(win);
        }
 private void TextBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     System.Windows.Interop.HwndSource source = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource;
     System.Windows.Forms.IWin32Window win    = new OldWindow(source.Handle);
     if (fs.ShowDialog(win) == System.Windows.Forms.DialogResult.OK)
     {
         VM_MA.SavePath = fs.DirectoryPath;
     }
 }
示例#10
0
 public static IWin32Window GetIWin32Window(this Visual visual)
 {
     var source = PresentationSource.FromVisual(visual) as HwndSource;
     if (source != null)
     {
         IWin32Window win = new OldWindow(source.Handle);
         return win;
     }
     throw (new Exception("GetIWin32Window failed for " + source));
 }
示例#11
0
        public static IWin32Window GetIWin32Window(this Visual visual)
        {
            var source = PresentationSource.FromVisual(visual) as HwndSource;

            if (source != null)
            {
                IWin32Window win = new OldWindow(source.Handle);
                return(win);
            }
            throw (new Exception("GetIWin32Window failed for " + source));
        }
示例#12
0
        private void TextBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            System.Windows.Interop.HwndSource source = PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource;
            System.Windows.Forms.IWin32Window win    = new OldWindow(source.Handle);
            FolderSelector fs = new FolderSelector()
            {
                DirectoryPath = string.IsNullOrEmpty(GlobalData.VM_MA.SavePath) ? Environment.CurrentDirectory : GlobalData.VM_MA.SavePath
            };

            if (fs.ShowDialog(win) == System.Windows.Forms.DialogResult.OK)
            {
                GlobalData.VM_MA.SavePath = fs.DirectoryPath;
            }
        }
示例#13
0
        private void SavePathTB_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var dlg = new FolderBrowserDialog
            {
                SelectedPath = SavePathTB.Text
            };
            var source = PresentationSource.FromVisual(this) as HwndSource;
            var win    = new OldWindow(source.Handle);
            var result = dlg.ShowDialog(win);

            if (result == System.Windows.Forms.DialogResult.OK)
            {
                SavePathTB.Text = dlg.SelectedPath;
            }
        }
        private void OnSaveLatentSvmTrainingSetButtonClick(object sender, RoutedEventArgs e)
        {
            FolderBrowserDialog dlg    = new FolderBrowserDialog();
            HwndSource          source = PresentationSource.FromVisual(this) as HwndSource;

            System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle);
            if (dlg.ShowDialog(win) != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            string directory = dlg.SelectedPath;

            using (StreamWriter writer = new StreamWriter(Path.Combine(directory, "all.txt")))
            {
                string colorModelsPath = Path.Combine(directory, "color_model.clr");
                this.colorModels.SaveToFile(colorModelsPath);
                writer.WriteLine(colorModelsPath);

                int index = 0;
                foreach (ImageInfo imageInfo in imageInfos)
                {
                    double       scale       = this.CalcSegmentedImageScale(imageInfo.Image);
                    Shape        scaledShape = imageInfo.Shape.Scale(scale, Vector.Zero);
                    BitmapSource scaledImage = ImageHelper.ResizeImage(
                        imageInfo.Image,
                        (int)Math.Round(imageInfo.Image.PixelWidth * scale),
                        (int)Math.Round(imageInfo.Image.PixelHeight * scale));
                    Image2D <Color> scaledConvertedImage = ImageHelper.BitmapSourceToImage2D(scaledImage);

                    string shapePath = Path.Combine(directory, string.Format("shape_{0:000}.s", index));
                    scaledShape.SaveToFile(shapePath);

                    string imagePath = Path.Combine(directory, string.Format("image_{0:000}.png", index));
                    Image2D.SaveToFile(scaledConvertedImage, imagePath);

                    writer.WriteLine("{0}\t{1}", shapePath, imagePath);
                    ++index;
                }
            }
        }
        private void OnSaveLatentSvmTrainingSetButtonClick(object sender, RoutedEventArgs e)
        {
            FolderBrowserDialog dlg = new FolderBrowserDialog();
            HwndSource source = PresentationSource.FromVisual(this) as HwndSource;
            System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle);
            if (dlg.ShowDialog(win) != System.Windows.Forms.DialogResult.OK)
                return;

            string directory = dlg.SelectedPath;
            using (StreamWriter writer = new StreamWriter(Path.Combine(directory, "all.txt")))
            {
                string colorModelsPath = Path.Combine(directory, "color_model.clr");
                this.colorModels.SaveToFile(colorModelsPath);
                writer.WriteLine(colorModelsPath);

                int index = 0;
                foreach (ImageInfo imageInfo in imageInfos)
                {
                    double scale = this.CalcSegmentedImageScale(imageInfo.Image);
                    Shape scaledShape = imageInfo.Shape.Scale(scale, Vector.Zero);
                    BitmapSource scaledImage = ImageHelper.ResizeImage(
                        imageInfo.Image,
                        (int)Math.Round(imageInfo.Image.PixelWidth * scale),
                        (int)Math.Round(imageInfo.Image.PixelHeight * scale));
                    Image2D<Color> scaledConvertedImage = ImageHelper.BitmapSourceToImage2D(scaledImage);

                    string shapePath = Path.Combine(directory, string.Format("shape_{0:000}.s", index));
                    scaledShape.SaveToFile(shapePath);

                    string imagePath = Path.Combine(directory, string.Format("image_{0:000}.png", index));
                    Image2D.SaveToFile(scaledConvertedImage, imagePath);

                    writer.WriteLine("{0}\t{1}", shapePath, imagePath);
                    ++index;
                }
            }
        }
示例#16
0
 public bool ShowDialog(System.Windows.Window window)
 {
     System.Windows.Interop.HwndSource source = System.Windows.PresentationSource.FromVisual(window) as System.Windows.Interop.HwndSource;
     System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle);
     return fd.ShowDialog(win) == System.Windows.Forms.DialogResult.OK;
 }
 public static IWin32Window GetIWin32Window(this System.Windows.Media.Visual visual)
 {
     var source = System.Windows.PresentationSource.FromVisual(visual) as System.Windows.Interop.HwndSource;
     IWin32Window win = new OldWindow(source.Handle);
     return win;
 }
示例#18
0
        //public static bool showTranslatedInfo(ITranslateableWindow window, String string_name, params string[] variables) {
        //    StringCollection mes = Strings.getStrings(string_name);
        //    return displayInfo(mes[StringType.Title].interpret(variables),
        //        mes[StringType.Message].interpret(variables));
        //}
        #endregion



        #region stuff for interacting with windows.forms controls
        // Ruthlessly stolen from http://stackoverflow.com/questions/315164/how-to-use-a-folderbrowserdialog-from-a-wpf-application
        public System.Windows.Forms.IWin32Window GetIWin32Window() {
            var source = System.Windows.PresentationSource.FromVisual(this) as System.Windows.Interop.HwndSource;
            System.Windows.Forms.IWin32Window win = new OldWindow(source.Handle);
            return win;
        }