Пример #1
0
        public MainWindow()
        {
            InitializeComponent();
            // 以下を追加
            this.btnDownload.Click += (sender, e) =>
            {
                var client = new System.Net.WebClient();
                byte[] buffer = client.DownloadData("http://k-db.com/?p=all&download=csv");
                string str = Encoding.Default.GetString(buffer);
                string[] rows = str.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

                // 1行目をラベルに表示
                this.lblTitle.Content = rows[0];
                // 2行目以下はカンマ区切りから文字列の配列に変換しておく
                List<string[]> list = new List<string[]>();
                rows.ToList().ForEach(row => list.Add(row.Split(new char[] { ',' })));
                // ヘッダの作成(データバインド用の設計)
                GridView view = new GridView();
                list.First().Select((item, cnt) => new { Count = cnt, Item = item }).ToList().ForEach(header =>
                {
                    view.Columns.Add(
                        new GridViewColumn()
                        {
                            Header = header.Item,
                            DisplayMemberBinding = new Binding(string.Format("[{0}]", header.Count))
                        });
                });
                // これらをリストビューに設定
                lvStockList.View = view;
                lvStockList.ItemsSource = list.Skip(1);
            };
        }
Пример #2
0
 private async void UpdateWeather()
 {
     try
     {
         _weatherList = await OpenWeather.HelperClass.Weather.GetWeather(Properties.Settings.Default.WeatherLocation);
         _currentWeather = _weatherList.First();
         _weatherForecast = _weatherList.Skip(1).ToList();
         tbCurrentLocation.Text = Properties.Settings.Default.WeatherLocation;
         //gridWeather.DataContext = _currentWeather;
         itemsControlForecase.DataContext = _weatherForecast;
         borderWeatherRight.DataContext = _currentWeather;
         borderWeatherStrip.DataContext = _currentWeather;
     }
     catch (System.Exception)
     {
     }
 }
Пример #3
0
 public void LoadMon(int NhomID)
 {
     lsMenuMon = BOMenuMon.GetAll(NhomID, _IsBanHang, _IsSoLuongChoPhepTonKho, _IsSoLuongKhongChoPhepTonKho, mTransit).ToList();
     if (lsMenuMon.Count > gridItems.Children.Count)
     {
         int CountItems = gridItems.Children.Count - 2;
         List<Data.BOMenuMon> lsItemsTem = lsMenuMon.Skip((PageItems - 1) * CountItems).Take(CountItems).ToList();
         bool Chay = true;
         int j = 0;
         for (int i = 0; i < lsItemsTem.Count; i++, j++)
         {
             if (i == 0)
             {
                 if (IsRefershMenu)
                     OnEventMenuMon(lsItemsTem[i]);
             }
             Chay = true;
             while (Chay)
             {
                 Chay = false;
                 if (Grid.GetRow(gridItems.Children[j]) != gridItems.RowDefinitions.Count - 1)
                     SetButtonItem((POSButtonMenu)gridItems.Children[j], lsItemsTem[i]);
                 else if (Grid.GetColumn(gridItems.Children[j]) > 0 && Grid.GetColumn(gridItems.Children[j]) < gridItems.ColumnDefinitions.Count - 1)
                     SetButtonItem((POSButtonMenu)gridItems.Children[j], lsItemsTem[i]);
                 else
                 {
                     Chay = true;
                     j++;
                 }
             }
         }
         if (lsItemsTem.Count > gridItems.Children.Count - gridItems.ColumnDefinitions.Count)
             j++;
         Chay = true;
         for (; j < gridItems.Children.Count; j++)
         {
             Chay = true;
             while (Chay)
             {
                 Chay = false;
                 if (Grid.GetRow(gridItems.Children[j]) != gridItems.RowDefinitions.Count - 1)
                     SetButtonEmpty((POSButtonMenu)gridItems.Children[j]);
                 else if (Grid.GetColumn(gridItems.Children[j]) > 0 && Grid.GetColumn(gridItems.Children[j]) < gridItems.ColumnDefinitions.Count - 1)
                     SetButtonEmpty((POSButtonMenu)gridItems.Children[j]);
                 else
                 {
                     Chay = true;
                     j++;
                     if (j > gridItems.Children.Count - 1)
                         Chay = false;
                 }
             }
         }
         SetItemPage(LoaiMenu.Mon);
     }
     else
     {
         for (int i = 0; i < lsMenuMon.Count; i++)
         {
             if (i == 0)
             {
                 if (IsRefershMenu)
                     OnEventMenuMon(lsMenuMon[i]);
             }
             SetButtonItem((POSButtonMenu)gridItems.Children[i], lsMenuMon[i]);
         }
         for (int i = lsMenuMon.Count; i < gridItems.Children.Count; i++)
         {
             SetButtonEmpty((POSButtonMenu)gridItems.Children[i]);
         }
         SetItemPage(LoaiMenu.None);
     }
 }
Пример #4
0
        public string CreateAnimatedString(string wrong, string right, List<Change> changes)
        {
            var word = wrong;
            foreach (var change in changes)
            {
                switch (change.ChangeType)
                {
                    case ChangeType.Insert:
                    {
                        word = word.Insert(change.Index, change.Character + "");
                        //when you insert a charahter the indexes will be effected so you need to push them
                        changes.Skip(changes.IndexOf(change) + 1).ToList().ForEach(f =>
                        {
                            f.Index++;
                            if (f.Index2.HasValue)
                                f.Index2++;
                        });
                    }
                    break;
                    case ChangeType.Remove:
                    //leav the char in there cuz the animation will take it out
                    break;
                    case ChangeType.Swap:
                    //leav them unswaped cuz the animation will do it 
                    break;
                    case ChangeType.Replace:
                    {
                        //put the new char next to the old one 
                        word = word.Insert(change.Index, change.Character2 + "");
                        //when you insert a charahter the indexes will be effected so you need to push them
                        changes.Skip(changes.IndexOf(change) + 1).ToList().ForEach(f =>
                        {
                            f.Index++;
                            if (f.Index2.HasValue)
                                f.Index2++;
                        });

                    }
                    break;
                }
            }
            return word;
        }
Пример #5
0
    private void Timer_Tick(object sender, EventArgs e) {

      InitializeVault();
      if (volumeInfo.Count == 0)
        return;

      List<Point> points = new List<Point>();
      for (int i = 0; i < volumeInfo.Count; i++) {
        var item = volumeInfo[volumeInfo.Count - i - 1];
        if ((DateTime.Now - item.TimeStamp).TotalMilliseconds > timeOnScreen)
          break;

        points.Add(new Point((DateTime.Now - item.TimeStamp).TotalMilliseconds * Width / timeOnScreen, Height - item.VolumeLevel * Height * 150));
      }

      if (points.Count > 0) {
        var pathGeom = new PathGeometry();
        pathGeom.Figures.Add(new PathFigure(points[0], points.Skip(1).Select(f => new LineSegment(f, true)), false));
        XPath.Data = pathGeom;  
      }
    }
Пример #6
0
        public void LoadGroup()
        {
            bool isHasMon = false;
            lsMenuNhom = BOMenuNhom.GetAll(LoaiNhomID, _IsBanHang, _IsSoLuongChoPhepTonKho, _IsSoLuongKhongChoPhepTonKho, mTransit).ToList();
            if (lsMenuNhom.Count > gridGroup.Children.Count)
            {
                int CountGroup = gridGroup.Children.Count - 2;
                List<Data.BOMenuNhom> lsGroupTem = lsMenuNhom.Skip((PageGroup - 1) * CountGroup).Take(CountGroup).ToList();
                for (int i = 0; i < lsGroupTem.Count; i++)
                {
                    if (i == 0)
                    {
                        MenuNhomIndex = lsGroupTem[i];
                        PageItems = 1;
                        LoadMon(lsMenuNhom[i].MenuNhom.NhomID);
                        OnEventMenuNhom(MenuNhomIndex);
                        isHasMon = true;
                    }
                    SetButtonNhom((POSButtonMenu)gridGroup.Children[i + 1], lsGroupTem[i]);
                }
                for (int i = lsGroupTem.Count; i < CountGroup; i++)
                {
                    SetButtonEmpty((POSButtonMenu)gridGroup.Children[i + 1]);
                }
                SetGroupPage();
            }
            else
            {
                for (int i = 0; i < lsMenuNhom.Count; i++)
                {
                    if (i == 0)
                    {
                        MenuNhomIndex = lsMenuNhom[i];
                        PageItems = 1;
                        LoadMon(lsMenuNhom[i].MenuNhom.NhomID);
                        OnEventMenuNhom(MenuNhomIndex);
                        isHasMon = true;
                    }
                    SetButtonNhom((POSButtonMenu)gridGroup.Children[i], lsMenuNhom[i]);
                }

                for (int i = lsMenuNhom.Count; i < gridGroup.Children.Count; i++)
                    SetButtonEmpty((POSButtonMenu)gridGroup.Children[i]);
            }
            if (isHasMon==false)
            {
                for (int i = 0; i < gridItems.Children.Count; i++)
                {
                    SetButtonEmpty((POSButtonMenu)gridItems.Children[i]);
                }
            }
        }
        /// <summary>
        /// 過去のもの。頑張りすぎた。
        /// </summary>
        /// <returns></returns>
        ClusteringResult Run2()
        {
            List<ClusteringResult> tmpResult = new List<ClusteringResult>();
            OnReport("開始");
            for (int i = 0; i < wideCount; i++)
            {
                ClusteringResult cr = new ClusteringResult() { Parent = this };
                cr.CreateRandom(ClusterTable, random.Next());
                tmpResult.Add(cr);
            }

            int loopCount = 0;
            int sameCount = 0;
            double sameRate = 0;
            while (true)
            {

                loopCount++;
                if (tmpResult.First().GetLockRate() == sameRate)
                {
                    sameCount++;
                }
                else
                {
                    sameRate = tmpResult.First().GetLockRate();
                    sameCount = 0;
                }

                OnReport(loopCount + "回目開始");
                foreach (var item in tmpResult)
                {
                    item.Run();
                }
                OnReport("計算終了");

                var baseResult = tmpResult.OrderByDescending(n => n.GetPerformanceIndex()).First();
                foreach (var item in tmpResult)
                {
                    item.CategorySort(baseResult);
                }
                tmpResult = tmpResult.OrderByDescending(n => n.GetPerformanceIndex()).ToList();
                List<ClusteringResult> list = new List<ClusteringResult>();
                foreach (var item in tmpResult.Take(tmpResult.Count / 2))
                {
                    var clone = item.Clone();
                    list.Add(clone);
                }
                if (tmpResult.Count > 3)
                {
                    foreach (var item in tmpResult.Skip(tmpResult.Count / 2).ToArray())
                    {
                        tmpResult.Remove(item);
                    }
                    foreach (var item in list)
                    {
                        tmpResult.Add(item.Clone());
                    }
                }

                if (tmpResult.First().GetLockRate() < 0.9 && loopCount < 100 && sameCount < 10)
                {
                    int c = 0;
                    OnReport("マージ・ランダム振り開始");
                    foreach (var item in tmpResult)
                    {
                        var count = item.CreateMargeData(list, true);
                        //  lock (this)
                        {
                            c += count;
                        }
                    }
                    OnReport("レポート開始");
                    OnReport(tmpResult.First().View());

                    if (c == 0) break;
                }
                else
                {
                    foreach (var item in tmpResult)
                    {
                        var count = item.CreateMargeData(list, false);
                    }
                    tmpResult.First().Run();
                    break;
                }

                if (tmpResult.First().DivideCategory())
                {
                    OnReport("クラスタ分割発生");
                    var r = tmpResult.First();
                    tmpResult.Clear();
                    for (int i = 0; i < TryCount; i++)
                    {
                        tmpResult.Add(r.Clone());
                    }
                }
                GC.Collect();
            }
            GC.Collect();
            OnReport("完了");
            return tmpResult.First();
        }
Пример #8
0
 void learningService_BookGetByBookTypeCompleted(object sender, BookGetByBookTypeCompletedEventArgs e)
 {
     try
     {
         take = loop;
         skip = 0;
         _BookList = new List<Book>();
         if (e.Error == null)
         {
             foreach (Book book in e.Result)
             {
                 _BookList.Add(book);
                 
             }
             List<Book> list = _BookList.Skip(skip).Take(take).ToList();
             foreach (Book _book in list)
             {
                 AddControl(0, new Thickness(0, 0, 0, 0), new Thickness(10, 0, 0, 0), 50.0, 80.0, 75.0, "../Images/Library/Data/" + _book.BookImg, _book.BookName, 11, _book.BookID, "Book", BookListStackPanel);
             }
             WaittingServices(false);
             TakeAndSkip();
         }
         else
             return;
     }
     catch
     {
         return;
     }
 }
Пример #9
0
        private void completeGame(List<List<GameState>> listOfGameStates)
        {
            var tempFinished = new List<GameState>();
            listOfGameStates.Reverse();
            tempFinished.Add(listOfGameStates.First().First(x => x.game.totalScore.score == listOfGameStates.First().Max(o => o.game.totalScore.score)));
            int index = 1;

            foreach (var round in listOfGameStates.Skip(1))//skip the first element cuz we just dealt with it above
            {
                tempFinished.Add(listOfGameStates[index].OrderByDescending(o => o.game.totalScore.score).ToList().First(
                    x => x.droppedPiece == tempFinished[index - 1].lastPiece));
                index++;
            }
            tempFinished.Reverse();
            finishedGame.AddRange(tempFinished);
        }
        private void SurfaceMode(HandCollection data)
        {
            this.Dispatcher.Invoke(new Action(() =>
            {
                if (isNew)
                {
                    if (this.selectedVideo != null)
                    {
                        this.selectedVideo.IsSelected = false;
                    }
                    this.selectedVideo = new VideoSurface(this.videoPaths[this.videoPointer++]);
                    this.videos.Add(this.selectedVideo);
                    this.selectedVideo.RequestRemove += new EventHandler(videoSurface_RequestRemove);
                    if (videoPointer >= this.videoPaths.Length)
                    {
                        videoPointer = 0;
                    }

                    this.viewPort.Children.Add(selectedVideo.ModelVisual3D);
                    this.selectedVideo.Play();
                    this.selectedVideo.Opacity = 0.8;
                    isNew = false;
                }
                if (selectedVideo.IsPaused)
                {
                    selectedVideo.Play();
                }

                var points = new List<CCT.NUI.Core.Point>();

                var hand1 = data.Hands[0];
                var hand2 = data.Hands[1];

                points.Add(hand1.FingerPoints[0].Fingertip);
                points.Add(hand1.FingerPoints[1].Fingertip);
                points.Add(hand2.FingerPoints[0].Fingertip);
                points.Add(hand2.FingerPoints[1].Fingertip);

                points = points.OrderBy((p) => p.X).ToList();
                var leftPoints = points.Take(2).ToList();
                var rightPoints = points.Skip(2).Take(2).ToList();
                leftPoints = leftPoints.OrderByDescending(p => p.Y).ToList();
                rightPoints = rightPoints.OrderByDescending(p => p.Y).ToList();

                this.selectedVideo.SetPoints(Map(leftPoints[0]), Map(rightPoints[0]), Map(rightPoints[1]), Map(leftPoints[1]));
            }));
            moveMode = false;
        }
Пример #11
0
        private void updateAnimListBox()
        {
            List<CurvePoint> points = new List<CurvePoint>();

            foreach (var p in selectedLine.points)
            {
                points.Add(new CurvePoint(p.time, p.weight, p.inTangent, p.leaveTangent));
            }
            List<Animation> anims = new List<Animation>();
            int pos = 0;
            int animLength;
            for (int i = 0; i < selectedLine.animations.Length; i++)
            {
                animLength = selectedLine.numKeys[i];
                anims.Add(new Animation
                {
                    Name = FaceFX.Header.Names[selectedLine.animations[i].index],
                    points = new LinkedList<CurvePoint>(points.Skip(pos).Take(animLength))
                });
                pos += animLength;
            }
            animationListBox.ItemsSource = anims;
            graph.Clear();
        }