コード例 #1
0
        //The exception is not in the ViewModel code. I found it by looking at ItemsSource property of the chart from the UI thread autos

        void AddPoints()  // Adds new points to the collection
        {
            counter = 0;
            while (true)
            {
                if (Adding)
                {
                    if (i > 50)
                    {
                        plus = false;
                    }
                    if (i < -50)
                    {
                        plus = true;
                    }
                    i  = i + (plus ? 1 : -1);
                    a += 0.3;
                    b += i;
                    ExampleCollection.Add(new Point(a, -b));
                    counter++;
                    if (counter < 350)
                    {
                        Thread.Sleep(30);
                    }
                    else
                    {
                        Thread.Sleep(30);
                    }
                }
            }
        }
コード例 #2
0
        private void ReloadEverything()
        {
            // Set the caption
            string caption = "Transliterator Editor ";

            if (sourceLanguage != null)
            {
                caption += sourceLanguage.Code;
            }
            if (destinationLanguage != null)
            {
                caption += " -> " + destinationLanguage.Code;
            }
            Title = caption;

            // Load rules
            rules = new RuleCollection(repository);
            dataGridRules.ItemsSource                = rules;
            transliterator                           = new Transliterator(repository, sourceLanguage.Code, destinationLanguage.Code);
            TransliterationExample.Transliterator    = (s => transliterator.Transliterate(s, false));
            TransliterationExample.Trans_li_te_rator = (s => transliterator.Transliterate(s, true));
            rules.MyTransliterator                   = transliterator;

            // Load TransliterationExamples
            examplesCollection           = new ExampleCollection(repository);
            dataGridExamples.ItemsSource = examplesCollection;

            TransliterationExample.DestinationFunc = Oggy.TransliterationEditor.WordDistance.CalculateDistance;
            TextBox_TextChanged(null, null);
        }
コード例 #3
0
        private void AddExamples_Click(object sender, RoutedEventArgs e)
        {
            RuleCollection rules = (RuleCollection)(dataGridRules.ItemsSource);

            List <string> words = new List <string>();

            foreach (var rule in rules)
            {
                if (rule.Examples != null)
                {
                    words.AddRange(rule.Examples.Split(new char[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries));
                }
                if (rule.CounterExamples != null)
                {
                    words.AddRange(rule.CounterExamples.Split(new char[] { ' ', ',', ';' }, StringSplitOptions.RemoveEmptyEntries));
                }
            }

            ExampleCollection examples = (ExampleCollection)(dataGridExamples.ItemsSource);
            var wordsInExamples        = examples.Select(example => example.Source);

            // Show the dialog
            var addExamplesWindow = new AddExamples(words.Distinct().Except(wordsInExamples), examples);

            addExamplesWindow.ShowDialog();
        }
コード例 #4
0
ファイル: Mapping.xaml.cs プロジェクト: xhyangxianjun/ASMZZZ
        /// <summary>
        /// 图谱初始化
        /// </summary>
        /// <param name="rowCount">行数</param>
        /// <param name="columnCount">列数</param>
        /// <param name="dic_DieState_Color">芯片状态-颜色 字典</param>
        /// <param name="initialDieState">初始状态</param>
        public void Initial(int rowCount, int columnCount, List <InspectionDataView> list_InspectionDataView)
        {
            DataCollection.Clear();
            ExampleCollection.Clear();
            double cellWidth, cellHeight;

            RowCount    = rowCount;
            ColumnCount = columnCount;
            SetCellSize(RowCount, ColumnCount, out cellWidth, out cellHeight);
            for (int i = 0; i < rowCount; i++)
            {
                for (int j = 0; j < columnCount; j++)
                {
                    MappingData data = new MappingData();
                    data.BorderThickness   = DefaultBorderThickness;
                    data.Width             = cellWidth;
                    data.Height            = cellHeight;
                    data.VariableX         = j * data.Width;
                    data.VariableY         = i * data.Height;
                    data.RowIndex          = i;
                    data.ColumnIndex       = j;
                    data.DieState          = InspectionResult.SKIP;
                    data.NormalBorderColor = DefaultBorderColor;
                    DataCollection.Add(data);
                }
            }
            foreach (InspectionDataView dataView in list_InspectionDataView)
            {
                DataCollection[dataView.RowIndex * ColumnCount + dataView.ColumnIndex].DieState = dataView.InspectionResult;
                if (dataView.List_DefectData.Count != 0)
                {
                    string[] defectTypeStrings = new string[dataView.List_DefectData.Count];
                    for (int i = 0; i < dataView.List_DefectData.Count; i++)
                    {
                        defectTypeStrings[i] = dataView.List_DefectData[i].ToString();
                    }
                    DataCollection[dataView.RowIndex * ColumnCount + dataView.ColumnIndex].DefectTypeIndexString = string.Join(";", defectTypeStrings);
                }
            }
            double fontSize = SetFontSize(cellWidth, cellHeight);

            foreach (MappingData data in DataCollection)
            {
                data.FontSize = fontSize;
            }

            foreach (KeyValuePair <InspectionResult, Color> kv in MappingData.Dict_DieState_Color)
            {
                ExampleData data = new ExampleData();
                data.DieState    = InspectionResultsConverter.ToString(kv.Key);
                data.FillColor   = kv.Value.ToString();
                data.BorderColor = DefaultBorderColor.ToString();
                data.Count       = DataCollection.Where(d => d.DieState == kv.Key).Count();
                ExampleCollection.Add(data);
            }
        }
コード例 #5
0
    public void IndexPropertyTest()
    {
        var MyExample = new ExampleCollection <string>();

        MyExample.Add("a");
        MyExample.Add("b");
        Assert.IsTrue(MyExample.ExampleProperty[0] == "a");
        Assert.IsTrue(MyExample.ExampleProperty[1] == "b");
        MyExample.ExampleProperty[0] = "c";
        Assert.IsTrue(MyExample.ExampleProperty[0] == "c");
    }
コード例 #6
0
        public AddExamples(IEnumerable <string> words, ExampleCollection examples)
            : this()
        {
            this.examples = examples;

            newExamples = new ExampleCollection(
                words.Select(word => new TransliterationExample()
            {
                Source = word
            }));
            dataGridExamples.ItemsSource = newExamples;
        }
コード例 #7
0
 public MainPageViewModel(ObservableCollection <Item> collection)
 {
     Task.Run(
         () =>
     {
         for (var i = 0; i < 50; i++)
         {
             collection.Add(new Item(i.ToString()));
         }
         Collection = new ExampleCollection <Item>(collection);
     });
 }
コード例 #8
0
        static void Main(string[] args)
        {
            //ExampleCollection.Merge_2FilesWith1Channel_To_OneFileWith2Channel();
            //ExampleCollection.CreateSampleWavFile();
            //WaveConcatenateHelper.Test();
            //ExampleCollection.CreatBigeSampleWavFile();
            ExampleCollection.TestTrimWavFile();
            //return;

            string wavParentFolder = @"E:\GS2018\E\Yang\Program\Git\GitYang\WaveProcess\WaveProcess\TestWavFile\WaveFiles";

            string[] wavFolders = Directory.GetDirectories(wavParentFolder);

            string concatenateOutputFolder = Path.GetDirectoryName(wavParentFolder) + "\\" + "EachWavFolderConcatenate";

            if (Directory.Exists(concatenateOutputFolder))
            {
                Directory.Delete(concatenateOutputFolder, true);
            }
            //如果檔案總管開在資料夾  一進行刪除  檔案總管會花時間跳出被刪除的資料夾
            //如果沒有停頓  底下的Create好像會因為時間差沒有效果 造成資料夾不存在的錯誤
            //所以這裡停頓
            Thread.Sleep(2000);
            Directory.CreateDirectory(concatenateOutputFolder);

            foreach (string wavFolder in wavFolders)
            {
                var folderFileTimes = FileNameProcessHelper.GetFolder_FileTimes(wavFolder);
                WaveConcatenateHelper.ProcessSlienceAndConcatenate(concatenateOutputFolder, folderFileTimes);
            }

            string outputFolderPath = Path.GetDirectoryName(concatenateOutputFolder) + "\\" + "Result";

            if (Directory.Exists(outputFolderPath))
            {
                Directory.Delete(outputFolderPath, true);
            }
            Thread.Sleep(2000);
            Directory.CreateDirectory(outputFolderPath);

            MultiWaveChannelMergeHelper.ConcatenatedFiles_Merge2Channel
                (outputFolderPath, concatenateOutputFolder);
        }
コード例 #9
0
        public static CollectionDTO AsItemCollectionDTO(this ExampleCollection collection, bool includeItems)
        {
            var itemDTOs = new List <ItemDTO>();

            if (includeItems && collection.ExampleItems != null)
            {
                itemDTOs = collection.ExampleItems.Select(i => i.AsItemDTO()).ToList();
            }

            var collectionDTO = new CollectionDTO
            {
                ExampleCollectionId = collection.ExampleCollectionId,
                Name       = collection.Name,
                ItemDTOs   = itemDTOs,
                UpdateType = UpdateType.IsUnchanged
            };

            return(collectionDTO);
        }
コード例 #10
0
ファイル: Mapping.xaml.cs プロジェクト: xhyangxianjun/ASMZZZ
        /// <summary>
        /// 修改芯片状态
        /// </summary>
        /// <param name="rowIndex">行序号,从0开始</param>
        /// <param name="columnIndex">列序号,从0开始</param>
        /// <param name="state">芯片状态</param>
        public void SetDieState(int rowIndex, int columnIndex, InspectionResult inspectionResult)
        {
            if (!IsInitialized)
            {
                return;
            }
            MappingData data = DataCollection[rowIndex * ColumnCount + columnIndex];

            ExampleData example = ExampleCollection.Where(e => e.DieState == InspectionResultsConverter.ToString(data.DieState)).FirstOrDefault();

            example.Count--;

            data.DieState = inspectionResult;

            example = ExampleCollection.Where(e => e.DieState == InspectionResultsConverter.ToString(data.DieState)).FirstOrDefault();
            example.Count++;
            mappingViewModel.ChangeSelectedText(rowIndex, columnIndex, inspectionResult);

            ScrollToView(data);
        }
コード例 #11
0
 private void OnListExamples(ExampleCollection response, Dictionary <string, object> customData)
 {
     Log.Debug("ExampleAssistant.OnListExamples()", "Response: {0}", customData["json"].ToString());
     _listExamplesTested = true;
 }
コード例 #12
0
    //public List<String> GetList() {
    //   return list;
    //}
 public void TestExampleCollection() {
    Serializer serializer = new Persister();
    ExampleCollection list = serializer.read(ExampleCollection.class, LIST);
コード例 #13
0
ファイル: MainForm.cs プロジェクト: hilmiStudent/Pocitani
 private void LoadExamples()
 {
     _examples = new ExampleCollection("examples.xml");
 }