private void yIQToolStripMenuItem_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < FileListBox.Items.Count; i++)
            {
                FileListBox.SelectedItem = i;
                FileListBox.Refresh();
                OriginalImg1.Load(files[i]);

                OriginalImg2.SetSize(OriginalImg1);
                EasyImage.Oper(EArithmeticLogicOperation.Copy, new EC24(0, 0, 0), OriginalImg2);

                OriginalImg1.ColorSystem = EColorSystem.Rgb;
                EColorLookup1.ConvertFromRgb(EColorSystem.Yiq);
                EColorLookup1.Transform(OriginalImg1, OriginalImg2);

                //EC24Image2.Draw(pbImg2.CreateGraphics(), ScalingRatio);

                string path = settings.set_path() + "\\" + Path.GetFileName(files[i]);

                if (!Directory.Exists(settings.set_path()))
                {
                    Directory.CreateDirectory(settings.set_path());
                }

                OriginalImg2.SaveJpeg(path);
            }

            MessageBox.Show("YIQ轉換完成", "通知");
        }
        private void RemoveButton_Click(object sender, EventArgs e)
        {
            if (FileListBox.Items.Count > 0)
            {
                var newList = new List <string>();

                for (var index = 0; index < FileListBox.Items.Count; index++)
                {
                    if (!FileListBox.GetItemChecked(index))
                    {
                        newList.Add(FileListBox.Items[index].ToString());
                    }
                }

                FileListBox.Items.Clear();

                foreach (var item in newList)
                {
                    FileListBox.Items.Add(item);
                }

                if (FileListBox.Items.Count > 0)
                {
                    SelectMode = !SelectMode;
                }
                else
                {
                    SelectMode = true;
                }
            }
        }
Example #3
0
        private void PopTheTopOfListBox()
        {
            //if (FileListBox.SelectedItems.Count > -1)
            //{
            if (FileListBox.SelectedItem != null)
            {
                FileListBox.Items.Remove(FileListBox.SelectedItem);
            }

            FileListBox.Focus();
            //}
        }
        private void ApplySelectMode()
        {
            if (FileListBox.Items.Count > 0)
            {
                for (var index = 0; index < FileListBox.Items.Count; index++)
                {
                    FileListBox.SetItemChecked(index, SelectMode);
                }

                SelectMode = !SelectMode;
            }
        }
Example #5
0
 public void CheckSelectAllOrSelectPos(int pos)
 {
     if (FileListBox.Items.Count > pos)
     {
         if (SelectAllCheckBox.IsChecked ?? false)
         {
             FileListBox.SelectAll();
         }
         else
         {
             FileListBox.UnselectAll();
             FileListBox.SelectedIndex = pos;
         }
     }
 }
Example #6
0
        private void SelectAllButton_Click(object sender, RoutedEventArgs e)
        {
            if (FileListBox.Items.Count == 0)
            {
                return;
            }

            if (FileListBox.SelectedItems.Count == 0)
            {
                FileListBox.SelectAll();
            }
            else
            {
                FileListBox.UnselectAll();
            }
        }
Example #7
0
        private void LoadFolderButton_Click(object sender, EventArgs e)
        {
            DirectoryInfo dir = new DirectoryInfo(folder_path);

            DirectoryInfo[] dirArray = dir.GetDirectories();
            for (; FileListBox.Items.Count > 0;)
            {
                FileListBox.Items.Remove(FileListBox.Items[0]);
            }
            for (int i = 0; i < dirArray.Length; i++)
            {
                FileListBox.Items.Add(dirArray[i].Name);
            }
            FileListBox.SelectedIndex = 0;
            EventArgs e = new EventArgs();

            FileListBox.OnSelectedIndexChanged(e);
        }
 /// <summary>
 /// Fills the List Box with the Dynamo Files everytime the SelectedFolder Changes
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FillFileListBox(object sender, System.Windows.Controls.TextChangedEventArgs e)
 {
     try
     {
         selectedDirectory = this.selectedDirectoryLabel.Text;
         string   directory = selectedDirectory;
         string[] files     = Directory.GetFiles(directory, "*.dyn");
         this.FileListBox.Items.Clear();
         foreach (string file in files)
         {
             string fileName = Path.GetFileName(file);
             FileListBox.Items.Add(fileName);
         }
         FileListBox.SelectAll();
     }
     catch
     {
     }
 }
        private void grayToolStripMenuItem_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < FileListBox.Items.Count; i++)
            {
                FileListBox.SelectedItem = i;
                FileListBox.Refresh();
                OriginalImg1.Load(files[i]);
                GrayImg1.SetSize(OriginalImg1);
                EasyImage.Oper(EArithmeticLogicOperation.Copy, new EBW8(0), GrayImg1);
                EasyImage.Convert(OriginalImg1, GrayImg1);

                string path = settings.set_path() + "\\" + Path.GetFileName(files[i]);

                if (!Directory.Exists(settings.set_path()))
                {
                    Directory.CreateDirectory(settings.set_path());
                }

                GrayImg1.SaveJpeg(path);
            }

            MessageBox.Show("灰階化轉換完成", "通知");
        }
        private void vehicleToolStripMenuItem_Click(object sender, EventArgs e)
        {
            float PictureBoxSizeRatio, ImageSizeRatio;

            codedImage1ObjectSelection.FeretAngle = 0.00f;
            codedImage1Encoder.GrayscaleSingleThresholdSegmenter.WhiteLayerEncoded = true;
            codedImage1Encoder.GrayscaleSingleThresholdSegmenter.BlackLayerEncoded = false;
            codedImage1Encoder.SegmentationMethod = ESegmentationMethod.GrayscaleSingleThreshold;
            codedImage1Encoder.GrayscaleSingleThresholdSegmenter.Mode = EGrayscaleSingleThreshold.MinResidue;

            OriginalImg1.Load(files[0]);

            /*============================計算scaling ratio============================*/
            PictureBoxSizeRatio = (float)pbImg1.Width / pbImg1.Height;
            ImageSizeRatio      = (float)OriginalImg1.Width / OriginalImg1.Height;
            if (ImageSizeRatio > PictureBoxSizeRatio)
            {
                ScalingRatio = (float)pbImg1.Width / OriginalImg1.Width;
            }
            else
            {
                ScalingRatio = (float)pbImg1.Height / OriginalImg1.Height;
            }
            /*=========================================================================*/

            for (int i = 0; i < FileListBox.Items.Count; i++)
            {
                FileListBox.SelectedIndex = i;
                FileListBox.Refresh();
                OriginalImg1.Load(files[i]);
                OriginalImg1.Draw(pbImg1.CreateGraphics(), ScalingRatio);

                GrayImg1.SetSize(OriginalImg1);
                EasyImage.Oper(EArithmeticLogicOperation.Copy, new EBW8(0), GrayImg1);
                EasyImage.Convert(OriginalImg1, GrayImg1); //轉灰階

                EasyImage.Median(BackgroundGray, BackgroundGray);
                EasyImage.Median(GrayImg1, GrayImg1);
                EasyImage.Oper(EArithmeticLogicOperation.Subtract, GrayImg1, BackgroundGray, GrayImg1);

                EasyImage.Threshold(GrayImg1, GrayImg1, unchecked ((uint)EThresholdMode.MinResidue));

                EasyImage.ErodeBox(GrayImg1, GrayImg1, 1);  //侵蝕
                EasyImage.CloseBox(GrayImg1, GrayImg1, 10); //閉合

                codedImage1ObjectSelection.FeretAngle = 0.00f;
                codedImage1Encoder.Encode(GrayImg1, codedImage1);
                codedImage1ObjectSelection.Clear();
                codedImage1ObjectSelection.AddObjects(codedImage1);
                codedImage1ObjectSelection.AttachedImage = GrayImg1;
                codedImage1ObjectSelection.RemoveUsingUnsignedIntegerFeature(EFeature.RunCount, 1000, ESingleThresholdMode.Less); //移除RunCount小於1000的物件

                if (codedImage1ObjectSelection.ElementCount > 0)
                {
                    Console.WriteLine("(" + codedImage1ObjectSelection.GetElement(0).BoundingBoxCenterX + ", " + codedImage1ObjectSelection.GetElement(0).BoundingBoxCenterY + ")");
                }

                codedImage1.DrawFeature(pbImg1.CreateGraphics(), EDrawableFeature.BoundingBox, codedImage1ObjectSelection, ScalingRatio); // 把車的框框畫出來

                GrayImg1.Draw(pbImg2.CreateGraphics(), ScalingRatio);

                Console.WriteLine(files[i]);
            }
        }
	public void ResetIndex(FileListBox o) {}
	public short GetIndex(FileListBox o) {}
	public void SetIndex(FileListBox o, short Index) {}
	public bool ShouldSerializeIndex(FileListBox o) {}
Example #15
0
 /// <summary>
 /// ファイル全選択ボタン押下時
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnClickAllSelect(object sender, RoutedEventArgs e)
 {
     FileListBox.SelectAll();
     FileListBox.Focus();
 }
Example #16
0
 /// <summary>
 /// ファイル全選択解除ボタン押下時
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnClickAllUnSelect(object sender, RoutedEventArgs e)
 {
     FileListBox.SelectedItems.Clear();
     FileListBox.Focus();
 }
        private void excelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Excel_APP1 = new Excel.Application();
            Excel_WB1  = Excel_APP1.Workbooks.Add();
            Excel_WS1  = new Excel.Worksheet();

            saveFileDialog1.Filter = "Excel|*.xlsx";
            saveFileDialog1.Title  = "Save a Excel";

            Excel_WS1              = Excel_WB1.Worksheets[1];
            Excel_WS1.Name         = "Data";
            Excel_APP1.Cells[1, 1] = "圖片(.jpg)";
            Excel_APP1.Cells[1, 2] = "Profile下";
            Excel_APP1.Cells[1, 3] = "Profile上";

            OriginalImg1.Load(files[0]);

            /*============================計算scaling ratio============================*/
            float PictureBoxSizeRatio = (float)pbImg1.Width / pbImg1.Height;
            float ImageSizeRatio      = (float)OriginalImg1.Width / OriginalImg1.Height;

            if (ImageSizeRatio > PictureBoxSizeRatio)
            {
                ScalingRatio = (float)pbImg1.Width / OriginalImg1.Width;
            }
            else
            {
                ScalingRatio = (float)pbImg1.Height / OriginalImg1.Height;
            }
            /*=========================================================================*/

            for (int i = 0; i < FileListBox.Items.Count; i++)
            {
                FileListBox.SelectedIndex = i;
                FileListBox.Refresh();
                OriginalImg1.Load(files[i]);
                OriginalImg1.Draw(pbImg1.CreateGraphics(), ScalingRatio);

                //EC24Image2.SetSize(EC24Image1);
                //EasyImage.Oper(EArithmeticLogicOperation.Copy, new EC24(0, 0, 0), EC24Image2);

                //EC24Image1.ColorSystem = EColorSystem.Rgb;
                //EColorLookup1.ConvertFromRgb(EColorSystem.Yiq);
                //EColorLookup1.Transform(EC24Image1, EC24Image2);

                //EC24Image2.Draw(pbImg2.CreateGraphics(), ScalingRatio);

                GrayImg1.SetSize(OriginalImg1);
                EasyImage.Oper(EArithmeticLogicOperation.Copy, new EBW8(0), GrayImg1);
                EasyImage.Convert(OriginalImg1, GrayImg1); //轉灰階

                //EasyImage.Oper(EArithmeticLogicOperation.Subtract, GrayImg1, BackgroundGray, GrayImg1);
                //EasyImage.Threshold(GrayImg1, GrayImg1, 56);
                //EasyImage.OpenBox(GrayImg1, GrayImg1, settings.set_value_3());

                GrayImg1.Draw(pbImg2.CreateGraphics(), ScalingRatio);

                EasyImage.ImageToLineSegment(GrayImg1, In, 1485, 700, 1683, 700);  //設定車子進入的偵測線,判斷車子是否準備進來
                EasyImage.ImageToLineSegment(GrayImg1, Out, 1485, 400, 1683, 400); //設定車子出去的偵測線,判斷車子是否準備出去

                Excel_APP1.Cells[2 + i, 1] = Path.GetFileNameWithoutExtension(files[i]);
                Excel_APP1.Cells[2 + i, 2] = getProfileValueSum(In);
                Excel_APP1.Cells[2 + i, 3] = getProfileValueSum(Out);

                //Console.WriteLine(files[i]);
            }

            if (saveFileDialog1.ShowDialog() == DialogResult.OK && saveFileDialog1.FileName != "")
            {
                Excel_WB1.SaveAs(saveFileDialog1.FileName);
            }

            Excel_WS1 = null;
            Excel_WB1.Close();
            Excel_WB1 = null;
            Excel_APP1.Quit();
            Excel_APP1 = null;
        }
Example #18
0
 public short GetIndex(FileListBox o)
 {
 }
Example #19
0
 public void SetIndex(FileListBox o, short Index)
 {
 }
Example #20
0
 public bool ShouldSerializeIndex(FileListBox o)
 {
 }
Example #21
0
 public void ResetIndex(FileListBox o)
 {
 }
        //--------------------------------------------//
        #endregion

        #region DataReceived
        //--------------------------------------------//

        private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            SerialPort currentPort = (SerialPort)sender;

            Thread.Sleep(200);
            try
            {
                String sign = currentPort.ReadLine();
                switch (sign)
                {
                case "a":                          //port parmeters changed
                    currentPort.DiscardInBuffer(); // discard current data, if exsist
                    TopMessageBox.AppendText("Controller Parameters changed !");
                    closePort();                   //close the port
                    ChangePara.Enabled   = true;   // enabled change in pc parametrs
                    SendPara.Enabled     = false;
                    ControllerParaChange = true;   // the controller has change his parameters
                    break;

                case "l":     //recieve list of files
                    FileListBox.BeginInvoke(new EventHandler(delegate { FileListBox.Items.Clear(); }));
                    string list = currentPort.ReadLine();
                    if (list == " ")
                    {
                        FileListBox.Items.Add("No files");
                    }
                    else
                    {
                        while (list != ">")     // ='>'.
                        {
                            FileListBox.BeginInvoke(new EventHandler(delegate { FileListBox.Items.Add(list.ToString()); }));
                            Thread.Sleep(150);
                            list = currentPort.ReadLine();
                        }
                    }
                    break;

                case "U":     // Recieve controler port parameters - optional
                    string parameters = "Baud rate : " + currentPort.ReadLine() + " BPS, "
                                        + currentPort.ReadLine() + " Data bits,";
                    parameters += " 1 Start," + StopBit.ToString() + " Stop bit,";
                    currentPort.ReadLine();
                    parameters += currentPort.ReadLine() + " Parity";
                    sign        = currentPort.ReadLine(); // for the final signal '>'
                    TopMessageBox.AppendText(parameters);
                    break;

                case "S":                                               // Recieve file
                    string current = currentPort.ReadExisting();
                    current = current.Substring(0, current.Length - 3); // dont save the last char '>' and 0x1A
                    string path      = PathBox.Text;
                    string namefile  = FileName.Text + ".txt";
                    int    Duplicate = 0;
                    try
                    {
                        while (File.Exists(Path.Combine(path, namefile)))
                        {
                            Duplicate++;
                            namefile = FileName.Text + Duplicate.ToString() + ".txt";
                        }

                        using (FileStream fileToSave = File.Create(Path.Combine(path, namefile)))
                        {
                            Byte[] data = new UTF8Encoding(true).GetBytes(current);
                            fileToSave.Write(data, 0, data.Length);
                        }
                        TopMessageBox.AppendText("File saved !");
                    }
                    catch { TopMessageBox.AppendText("Error oucerd !"); }
                    break;

                case "D":
                    TopMessageBox.AppendText("File saved in the controller ! \n");
                    currentPort.ReadLine();
                    break;

                default:      // discard current data, if exsist
                    currentPort.ReadExisting();
                    break;
                }
            }
            catch { port.DiscardInBuffer(); }
        }
Example #23
0
        public CodeSearchControl()
        {
            InitializeComponent();
            // Add the "VsColors" brushes to the WPF resources of the control, so that the
            // resource keys used on the XAML file can be resolved dynamically.
            Resources.MergedDictionaries.Add(VsResources.BuildResourceDictionary());
            DataContext = new CodeSearchViewModel();

            _progressBarTracker = new ProgressBarTracker(ProgressBar);

            InitComboBox(SearchCodeCombo, new ComboBoxInfo {
                TextChanged    = text => { ViewModel.SearchCodeValue = text; },
                SearchFunction = RefreshSearchResults,
                NextElement    = SearchFilePathsCombo,
            });
            InitComboBox(SearchFilePathsCombo, new ComboBoxInfo {
                TextChanged     = text => { ViewModel.SearchFilePathsValue = text; },
                SearchFunction  = RefreshSearchResults,
                PreviousElement = SearchCodeCombo,
                InitialItems    =
                {
                    "*",
                    "*.c;*.cpp;*.cxx;*.cc;*.tli;*.tlh;*.h;*.hh;*.hpp;*.hxx;*.hh;*.inl;*.rc;*.resx;*.idl;*.asm;*.inc",
                    "*.htm;*.html;*.xml;*.gif;*.jpg;*.png;*.css;*.disco;*.js;*.srf",
                    "*.xml;*.xsl;*.xslt;*.xsd;*.dtd",
                    "*.txt",
                    "*.cs;*.resx;*.resw;*.xsd;*.wsdl;*.xaml;*.xml;*.htm;*.html;*.css",
                    "*.vb;*.resx;*.resw;*.xsd;*.wsdl;*.xaml;*.xml;*.htm;*.html;*.css",
                    "*.*",
                }
            });

            // Setup custom NextElement logic to account for swapping tree/list views
            SearchFilePathsCombo.PrePreviewKeyDown += (s, e) => {
                if (e.KeyboardDevice.Modifiers == ModifierKeys.None && e.Key == Key.Down)
                {
                    if (!SearchFilePathsCombo.IsDropDownOpen)
                    {
                        if (ViewModel.FlattenSearchResults)
                        {
                            FileListBox.Focus();

                            if (FileListBox.SelectedItem == null)
                            {
                                FileListBox.SelectedIndex = 0;
                            }

                            var listBoxItem = (ListBoxItem)FileListBox.ItemContainerGenerator.ContainerFromItem(FileListBox.SelectedItem);
                            if (listBoxItem != null)
                            {
                                listBoxItem.Focus();
                            }
                        }
                        else
                        {
                            FileTreeView.Focus();
                        }
                        e.Handled = true;
                    }
                }
            };
        }