private void CheckIfFileExists()
 {
     if (!_isInFileMode)
     {
         return;
     }
     if (string.IsNullOrEmpty(SelectedPath))
     {
         CanAccept = false;
         return;
     }
     if (File.Exists(SelectedPath))
     {
         SetError(PathTextBox, Application.Current.Resources["FileAlreadyExists"].ToString());
         CanAccept = false;
     }
     else
     {
         var expression = PathTextBox.GetBindingExpression(TextBox.TextProperty);
         if (expression != null)
         {
             Validation.ClearInvalid(expression);
         }
         CanAccept = true;
     }
 }
Exemple #2
0
 private void PathTextBox_LostFocus(object sender, RoutedEventArgs e)
 {
     if (PathTextBox.Text.Equals(""))
     {
         PathTextBox.AppendText(@"Begin at search path - example „D:\");
     }
 }
Exemple #3
0
        public MainWindow()
        {
            InitializeComponent();

            PathTextBox.AddHandler(TextBox.DragOverEvent, new DragEventHandler(PathTextBox_DragOver), true);
            PathTextBox.AddHandler(TextBox.DropEvent, new DragEventHandler(PathTextBox_Drop), true);
        }
Exemple #4
0
        private void PathTextBox_GotFocus(object sender, RoutedEventArgs e)
        {
            PathTextBox.Text = string.Empty;
            PathTextBox.AppendText(new Explorer().OpenExplorer());

            if (PathTextBox.Text.Equals(""))
            {
                PathTextBox.AppendText(@"Begin at search path - example „D:\");
            }
        }
Exemple #5
0
        public AddNewFileSourceDialog()
        {
            _input = new JsonFileInput();

            InitializeComponent();

            // sigh, too bad reactiveui doesn't support .net 4
            Action doValidation = () =>
            {
                var path  = PathTextBox.Text;
                var count = NumRowsToSampleTextBox.Text;

                int nr;
                var pathOk  = File.Exists(path) || String.IsNullOrEmpty(path);
                var countOk = Int32.TryParse(count, out nr) && nr > 0;

                OkButton.IsEnabled = (pathOk && countOk && !String.IsNullOrEmpty(path));

                PathTextBox.Background            = pathOk ? _goodBrush : _badBrush;
                NumRowsToSampleTextBox.Background = countOk ? _goodBrush : _badBrush;
            };

            PathTextBox.TextChanged            += (sender, args) => doValidation();
            NumRowsToSampleTextBox.TextChanged += (sender, args) => doValidation();

            BrowseButton.Click += (sender, args) =>
            {
                var fileDialog = new OpenFileDialog
                {
                    Multiselect     = false,
                    CheckFileExists = true,
                };

                var result = fileDialog.ShowDialog();

                if (result.HasValue && result.Value)
                {
                    PathTextBox.Text = fileDialog.FileName;
                }
            };

            CancelButton.Click += (sender, args) => DialogResult = false;
            OkButton.Click     += (sender, args) =>
            {
                _input.InputPath       = PathTextBox.Text;
                _input.NumRowsToSample = Math.Max(0, Int32.Parse(NumRowsToSampleTextBox.Text));

                Input        = _input;
                DialogResult = true;
            };

            doValidation();

            PathTextBox.Focus();
        }
Exemple #6
0
        public AddNewFolderSourceDialog()
        {
            _input = new JsonFileInput();

            InitializeComponent();

            // sigh, too bad reactiveui doesn't support .net 4
            Action doValidation = () =>
            {
                var path  = PathTextBox.Text;
                var count = NumRowsToSampleTextBox.Text;

                int nr;
                var pathOk  = Directory.Exists(path) || String.IsNullOrEmpty(path);
                var countOk = Int32.TryParse(count, out nr) && nr > 0;

                OkButton.IsEnabled = (pathOk && countOk && !String.IsNullOrEmpty(path));

                PathTextBox.Background            = pathOk ? _goodBrush : _badBrush;
                NumRowsToSampleTextBox.Background = countOk ? _goodBrush : _badBrush;
            };

            PathTextBox.TextChanged            += (sender, args) => doValidation();
            NumRowsToSampleTextBox.TextChanged += (sender, args) => doValidation();

            BrowseButton.Click += (sender, args) =>
            {
                var fileDialog = new FolderSelectDialog();
                var result     = fileDialog.ShowDialog();

                if (result)
                {
                    PathTextBox.Text = fileDialog.FileName;
                }
            };

            CancelButton.Click += (sender, args) => DialogResult = false;
            OkButton.Click     += (sender, args) =>
            {
                _input.InputPath       = PathTextBox.Text;
                _input.Recursive       = (bool)RecurseCheckbox.IsChecked;
                _input.Mask            = String.IsNullOrWhiteSpace(FileMaskTextBox.Text) ? "*.*" : FileMaskTextBox.Text;
                _input.NumRowsToSample = Math.Max(0, Int32.Parse(NumRowsToSampleTextBox.Text));

                Input        = _input;
                DialogResult = true;
            };

            doValidation();

            PathTextBox.Focus();
        }
        private void Control_OnMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            FileDialog fd = new OpenFileDialog();

            fd.DefaultExt       = ".pem";
            fd.Filter           = "Digital certificate file (*.pem)|*.pem|Digital certificate file (*.crt)|*.crt";
            fd.InitialDirectory = Path.GetFullPath(Directory.GetCurrentDirectory() + @"\..\..\CryptoFiles\certs\");
            if (fd.ShowDialog() != true)
            {
                return;
            }
            var sourceFile = fd.FileName;

            PathTextBox.Text = sourceFile;
            PathTextBox.ScrollToEnd();
        }
    private void Search_OnClick(object sender, RoutedEventArgs e)
    {
        var ofd = new OpenFileDialog()
        {
            FileName         = "Select Folder.",
            InitialDirectory = PathTextBox.Text,
            ValidateNames    = false,
            CheckFileExists  = false,
            CheckPathExists  = false
        };

        if (ofd.ShowDialog(this) != true)
        {
            return;
        }
        PathTextBox !.Text = Path.GetDirectoryName(ofd.FileName) ?? "";
        PathTextBox.GetBindingExpression(TextBox.TextProperty)?.UpdateSource();
    }
Exemple #9
0
 private void PathTextBox_Enter(object sender, EventArgs e)
 {
     PathTextBox.SelectAll();
 }
Exemple #10
0
 private void PathTextBox_Initialized(object sender, EventArgs e)
 {
     PathTextBox.AppendText(@"Begin at search path - example „D:\");
 }
Exemple #11
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMain));
     this.pathBox            = new King.Windows.Forms.PathTextBox();
     this.label1             = new System.Windows.Forms.Label();
     this.textBoxResult      = new System.Windows.Forms.TextBox();
     this.statusBar          = new System.Windows.Forms.StatusBar();
     this.label2             = new System.Windows.Forms.Label();
     this.label3             = new System.Windows.Forms.Label();
     this.buttonCompute      = new System.Windows.Forms.Button();
     this.imageList          = new System.Windows.Forms.ImageList(this.components);
     this.numericUpDownLevel = new System.Windows.Forms.NumericUpDown();
     this.label4             = new System.Windows.Forms.Label();
     this.buttonMove         = new System.Windows.Forms.Button();
     this.label5             = new System.Windows.Forms.Label();
     this.numericUpDownSize  = new System.Windows.Forms.NumericUpDown();
     this.toolTip            = new System.Windows.Forms.ToolTip(this.components);
     this.comboBoxUnits      = new System.Windows.Forms.ComboBox();
     ((System.ComponentModel.ISupportInitialize)(this.numericUpDownLevel)).BeginInit();
     ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSize)).BeginInit();
     this.SuspendLayout();
     //
     // pathBox
     //
     this.pathBox.AllowDrop = true;
     this.pathBox.Anchor    = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                                                                    | System.Windows.Forms.AnchorStyles.Right)));
     this.pathBox.ButtonText  = "Browse&...";
     this.pathBox.Description = "Select the directory you wish to select files from.";
     this.pathBox.Location    = new System.Drawing.Point(9, 27);
     this.pathBox.Name        = "pathBox";
     this.pathBox.Size        = new System.Drawing.Size(601, 22);
     this.pathBox.TabIndex    = 1;
     this.toolTip.SetToolTip(this.pathBox, "Directory to pick files from.");
     //
     // label1
     //
     this.label1.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
     this.label1.Location   = new System.Drawing.Point(7, 11);
     this.label1.Name       = "label1";
     this.label1.Size       = new System.Drawing.Size(100, 13);
     this.label1.TabIndex   = 0;
     this.label1.Text       = "Source &path:";
     //
     // textBoxResult
     //
     this.textBoxResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                        | System.Windows.Forms.AnchorStyles.Left)
                                                                       | System.Windows.Forms.AnchorStyles.Right)));
     this.textBoxResult.Location   = new System.Drawing.Point(8, 128);
     this.textBoxResult.Multiline  = true;
     this.textBoxResult.Name       = "textBoxResult";
     this.textBoxResult.ReadOnly   = true;
     this.textBoxResult.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
     this.textBoxResult.Size       = new System.Drawing.Size(612, 263);
     this.textBoxResult.TabIndex   = 10;
     this.toolTip.SetToolTip(this.textBoxResult, "The best combination of files found by the program to fill the target size.");
     //
     // statusBar
     //
     this.statusBar.Location = new System.Drawing.Point(0, 399);
     this.statusBar.Name     = "statusBar";
     this.statusBar.Size     = new System.Drawing.Size(637, 22);
     this.statusBar.TabIndex = 11;
     //
     // label2
     //
     this.label2.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
     this.label2.Location   = new System.Drawing.Point(7, 59);
     this.label2.Name       = "label2";
     this.label2.Size       = new System.Drawing.Size(69, 15);
     this.label2.TabIndex   = 2;
     this.label2.Text       = "&Target size:";
     //
     // label3
     //
     this.label3.Location = new System.Drawing.Point(78, 59);
     this.label3.Name     = "label3";
     this.label3.Size     = new System.Drawing.Size(62, 15);
     this.label3.TabIndex = 6;
     this.label3.Text     = "MB";
     //
     // buttonCompute
     //
     this.buttonCompute.Anchor     = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     this.buttonCompute.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
     this.buttonCompute.ImageIndex = 0;
     this.buttonCompute.ImageList  = this.imageList;
     this.buttonCompute.Location   = new System.Drawing.Point(390, 64);
     this.buttonCompute.Name       = "buttonCompute";
     this.buttonCompute.Size       = new System.Drawing.Size(107, 42);
     this.buttonCompute.TabIndex   = 7;
     this.buttonCompute.Text       = "&Compute";
     this.toolTip.SetToolTip(this.buttonCompute, "Start searching for best combination of files.");
     this.buttonCompute.Click += new System.EventHandler(this.buttonCompute_Click);
     //
     // imageList
     //
     this.imageList.ImageStream      = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
     this.imageList.TransparentColor = System.Drawing.Color.Transparent;
     this.imageList.Images.SetKeyName(0, "");
     this.imageList.Images.SetKeyName(1, "");
     //
     // numericUpDownLevel
     //
     this.numericUpDownLevel.Location = new System.Drawing.Point(89, 82);
     this.numericUpDownLevel.Minimum  = new decimal(new int[] {
         1,
         0,
         0,
         0
     });
     this.numericUpDownLevel.Name     = "numericUpDownLevel";
     this.numericUpDownLevel.Size     = new System.Drawing.Size(53, 20);
     this.numericUpDownLevel.TabIndex = 6;
     this.toolTip.SetToolTip(this.numericUpDownLevel, "How far down in directories to pick single files/subfolders. Set to 1 for files/f" +
                             "olders in selected directory only (no subfiles/folders).");
     this.numericUpDownLevel.Value = new decimal(new int[] {
         1,
         0,
         0,
         0
     });
     //
     // label4
     //
     this.label4.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
     this.label4.Location   = new System.Drawing.Point(7, 84);
     this.label4.Name       = "label4";
     this.label4.Size       = new System.Drawing.Size(81, 15);
     this.label4.TabIndex   = 5;
     this.label4.Text       = "&Max recursion:";
     //
     // buttonMove
     //
     this.buttonMove.Anchor     = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     this.buttonMove.Enabled    = false;
     this.buttonMove.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
     this.buttonMove.ImageIndex = 1;
     this.buttonMove.ImageList  = this.imageList;
     this.buttonMove.Location   = new System.Drawing.Point(501, 64);
     this.buttonMove.Name       = "buttonMove";
     this.buttonMove.Size       = new System.Drawing.Size(107, 42);
     this.buttonMove.TabIndex   = 8;
     this.buttonMove.Text       = "&Move files";
     this.toolTip.SetToolTip(this.buttonMove, "Move the best match files to a directory of your choice.");
     this.buttonMove.Click += new System.EventHandler(this.buttonMove_Click);
     //
     // label5
     //
     this.label5.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
     this.label5.Location   = new System.Drawing.Point(7, 111);
     this.label5.Name       = "label5";
     this.label5.Size       = new System.Drawing.Size(100, 16);
     this.label5.TabIndex   = 9;
     this.label5.Text       = "Selected files:";
     //
     // numericUpDownSize
     //
     this.numericUpDownSize.DecimalPlaces = 1;
     this.numericUpDownSize.Location      = new System.Drawing.Point(75, 57);
     this.numericUpDownSize.Maximum       = new decimal(new int[] {
         2000,
         0,
         0,
         0
     });
     this.numericUpDownSize.Minimum = new decimal(new int[] {
         1,
         0,
         0,
         0
     });
     this.numericUpDownSize.Name     = "numericUpDownSize";
     this.numericUpDownSize.Size     = new System.Drawing.Size(55, 20);
     this.numericUpDownSize.TabIndex = 3;
     this.toolTip.SetToolTip(this.numericUpDownSize, "The (maximum) size you wish the selected files to occupy.");
     this.numericUpDownSize.Value = new decimal(new int[] {
         700,
         0,
         0,
         0
     });
     //
     // toolTip
     //
     this.toolTip.AutoPopDelay = 5000;
     this.toolTip.InitialDelay = 400;
     this.toolTip.ReshowDelay  = 100;
     //
     // comboBoxUnits
     //
     this.comboBoxUnits.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     this.comboBoxUnits.Items.AddRange(new object[] {
         "KB",
         "MB",
         "GB"
     });
     this.comboBoxUnits.Location = new System.Drawing.Point(134, 57);
     this.comboBoxUnits.Name     = "comboBoxUnits";
     this.comboBoxUnits.Size     = new System.Drawing.Size(40, 21);
     this.comboBoxUnits.TabIndex = 4;
     //
     // FormMain
     //
     this.AcceptButton      = this.buttonCompute;
     this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
     this.ClientSize        = new System.Drawing.Size(637, 421);
     this.Controls.Add(this.comboBoxUnits);
     this.Controls.Add(this.numericUpDownSize);
     this.Controls.Add(this.label5);
     this.Controls.Add(this.buttonMove);
     this.Controls.Add(this.label4);
     this.Controls.Add(this.numericUpDownLevel);
     this.Controls.Add(this.buttonCompute);
     this.Controls.Add(this.label3);
     this.Controls.Add(this.label2);
     this.Controls.Add(this.statusBar);
     this.Controls.Add(this.textBoxResult);
     this.Controls.Add(this.label1);
     this.Controls.Add(this.pathBox);
     this.Icon        = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
     this.MinimumSize = new System.Drawing.Size(408, 256);
     this.Name        = "FormMain";
     this.Closing    += new System.ComponentModel.CancelEventHandler(this.FormMain_Closing);
     this.Load       += new System.EventHandler(this.FormMain_Load);
     ((System.ComponentModel.ISupportInitialize)(this.numericUpDownLevel)).EndInit();
     ((System.ComponentModel.ISupportInitialize)(this.numericUpDownSize)).EndInit();
     this.ResumeLayout(false);
     this.PerformLayout();
 }
 void BrowseButton_Click(Object sender, RoutedEventArgs e) => PathTextBox.Browse();
        public AddInteractionEditPage(GingerAction act)
        {
            InitializeComponent();

            mAct = act;

            ActionParam AP1 = mAct.GetOrCreateParam("ProviderState");

            ProviderStateTextBox.BindControl(AP1);

            ActionParam AP2 = mAct.GetOrCreateParam("Description");

            DescriptionTextBox.BindControl(AP2);

            List <ComboBoxListItem> HTTPMethodList = new List <ComboBoxListItem>();

            HTTPMethodList.Add(new ComboBoxListItem()
            {
                Text = "Get", Value = "Get"
            });
            HTTPMethodList.Add(new ComboBoxListItem()
            {
                Text = "Head", Value = "Head"
            });
            HTTPMethodList.Add(new ComboBoxListItem()
            {
                Text = "Not Set", Value = "NotSet"
            });
            HTTPMethodList.Add(new ComboBoxListItem()
            {
                Text = "Patch", Value = "Patch"
            });
            HTTPMethodList.Add(new ComboBoxListItem()
            {
                Text = "Post", Value = "Post"
            });
            HTTPMethodList.Add(new ComboBoxListItem()
            {
                Text = "Put", Value = "Put"
            });

            ActionParam AP3 = mAct.GetOrCreateParam("RequestTypeComboBox");

            RequestMethodComboBox.BindControl(AP3, HTTPMethodList);

            ActionParam AP5 = mAct.GetOrCreateParam("Path");

            PathTextBox.BindControl(AP5);

            List <ComboBoxListItem> StatusList = new List <ComboBoxListItem>();

            StatusList.Add(new ComboBoxListItem()
            {
                Text = "OK", Value = "200"
            });
            StatusList.Add(new ComboBoxListItem()
            {
                Text = "Created", Value = "201"
            });
            StatusList.Add(new ComboBoxListItem()
            {
                Text = "No Content", Value = "204"
            });
            StatusList.Add(new ComboBoxListItem()
            {
                Text = "Not Modified", Value = "304"
            });
            StatusList.Add(new ComboBoxListItem()
            {
                Text = "Bad Request", Value = "400"
            });
            StatusList.Add(new ComboBoxListItem()
            {
                Text = "Unauthorized", Value = "401"
            });
            StatusList.Add(new ComboBoxListItem()
            {
                Text = "Forbidden", Value = "403"
            });
            StatusList.Add(new ComboBoxListItem()
            {
                Text = "Not Found", Value = "404"
            });
            StatusList.Add(new ComboBoxListItem()
            {
                Text = "Conflict", Value = "409"
            });
            StatusList.Add(new ComboBoxListItem()
            {
                Text = "Internal Server Error", Value = "500"
            });
            StatusList.Add(new ComboBoxListItem()
            {
                Text = "Service Unavailable", Value = "503"
            });

            //TODO: after the above most common enable the user to see all available http code: http://www.restapitutorial.com/httpstatuscodes.html

            //TODO: fill the rest
            ActionParam AP4 = mAct.GetOrCreateParam("Status");

            ResponseStatusComboBox.BindControl(AP4, StatusList);
            RequestHeadersGrid.ItemsSource  = RequestHeaders;
            RepsonseHeadersGrid.ItemsSource = ResponseHeaders;
        }