Exemplo n.º 1
0
        public Statistiques()
        {
            int nbStats = 0;

            Stats = new TrulyObservableCollection <Statistique>();
            Stats.Add(new Statistique("Élimination(s)", nbStats++));
            Stats.Add(new Statistique("Mort(s)", nbStats++));
            Stats.Add(new Statistique("Assistance(s)", nbStats++));
            Stats.Add(new Statistique("Batiment(s) détruit(s)", nbStats++));

            Stats.ItemPropertyChanged += PropertyChanged;
        }
Exemplo n.º 2
0
 public static void AddRule(Rule rule)
 {
     if (!Rules.Contains(rule))
     {
         Rules.Add(rule);
         rule.Conclusion.ClearCache();
         ConcreteObservations.Remove(rule.Conclusion);
         foreach (var concreteObservation in rule.ConcreteObservations)
         {
             if (!ConcreteObservations.Contains(concreteObservation) && !concreteObservation.IsConclusion())
             {
                 ConcreteObservations.Add(concreteObservation);
             }
         }
     }
 }
Exemplo n.º 3
0
        private static void Main(string[] args)
        {
            var autoReset     = new AutoResetEvent(false);
            var r             = new Random();
            var o             = new TrulyObservableCollection <DataPoint>();
            var subscription1 = Observable.Interval(TimeSpan.FromSeconds(1)).Take(3).Subscribe(
                i =>
            {
                o.Add(
                    new DataPoint
                {
                    ItemCount = r.Next(100)
                });
                Console.WriteLine("Fire1 {0}", i);
            });
            var subscription2 =
                Observable.FromEventPattern <NotifyCollectionChangedEventArgs>(o, "CollectionChanged")
                .Subscribe(s => { Console.WriteLine("List changed. Current total {0}", o.Sum(s1 => s1.ItemCount)); });
            var subscription3 = Observable.Interval(TimeSpan.FromSeconds(1)).Delay(TimeSpan.FromSeconds(3)).Take(3).Finally(
                () =>
            {
                o.Clear();
                autoReset.Set();
            }).Subscribe(
                i =>
            {
                if (o.Any())
                {
                    o[r.Next(o.Count)].ItemCount = r.Next(100);
                    Console.WriteLine("Fire3 {0}", i);
                }
            });

            autoReset.WaitOne();
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            //this.sbShowListViewItem.Begin();
            // ATTN: Please note it's a "TrulyObservableCollection" that's instantiated. Otherwise, "Trades[0].Qty = 999" will NOT trigger event handler "Trades_CollectionChanged" in main.
            // REF: http://stackoverflow.com/questions/8490533/notify-observablecollection-when-item-changes
            TrulyObservableCollection<Trade> Trades = new TrulyObservableCollection<Trade>();
            Trades.Add(new Trade { Symbol = "APPL", Qty = 123 });
            Trades.Add(new Trade { Symbol = "IBM", Qty = 456 });
            Trades.Add(new Trade { Symbol = "CSCO", Qty = 789 });

            Trades.CollectionChanged += Trades_CollectionChanged;
            //Trades.ItemPropertyChanged += PropertyChangedHandler;
            Trades.RemoveAt(2);

            Trades[0].Qty = 999;
        }
Exemplo n.º 5
0
 public Board(GameLocation gameLocation)
 {
     this.gameLocation = gameLocation;
     BoardMatrix       = new TrulyObservableCollection <TrulyObservableCollection <BoardField> >();
     for (var i = 0; i <= BoardSize; i++)
     {
         BoardMatrix.Add(new TrulyObservableCollection <BoardField>());
         for (var j = 0; j <= BoardSize; j++)
         {
             if (i % 2 == 0 && j % 2 == 0)
             {
                 BoardMatrix[i].Add(new BoardField
                 {
                     Position = new Position {
                         Y = i, X = j
                     },
                     FieldType = BoardElementType.Empty
                 });
             }
             else
             {
                 BoardMatrix[i].Add(new BoardField
                 {
                     Position = new Position {
                         Y = i, X = j
                     },
                     FieldType = BoardElementType.EmptyForWall
                 });
             }
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Saves the new selected item in the viewmodel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnLanguageBox_Changed(object sender, SelectionChangedEventArgs e)
        {
            _viewModel.CurrentLanguage = (sender as ComboBox).SelectedItem as string;
            WhiteList_Grid.ItemsSource = null;

            if (_viewModel.CurrentLanguage == "All")
            {
                _viewModel.CurrentWhiteList   = _viewModel.WhiteList;
                MainView_DataGrid.ItemsSource = null;
                MainView_DataGrid.ItemsSource = _viewModel.List;
            }
            else
            {
                // WhiteList

                List <WhiteList> tempList = new List <WhiteList>();

                foreach (WhiteList wl in _viewModel.WhiteList)
                {
                    if (wl.Language == _viewModel.CurrentLanguage)
                    {
                        tempList.Add(new WhiteList
                        {
                            Language  = wl.Language,
                            Extension = wl.Extension
                        });
                    }
                }

                _viewModel.CurrentWhiteList = tempList;
                TrulyObservableCollection <MyFile> tempFileList = new TrulyObservableCollection <MyFile>();

                // Filelist

                foreach (MyFile f in _viewModel.List)
                {
                    bool flag = false;
                    for (int i = 0; i < _viewModel.CurrentWhiteList.Count(); i++)
                    {
                        if (_viewModel.CurrentWhiteList[i].Extension == f.Extension)
                        {
                            tempFileList.Add(f);
                            flag = true;
                            break;
                        }
                    }
                    if (flag)
                    {
                        continue;
                    }
                }
                _viewModel.TempList           = tempFileList;
                MainView_DataGrid.ItemsSource = null;
                MainView_DataGrid.ItemsSource = _viewModel.TempList;
            }
            WhiteList_Grid.ItemsSource = _viewModel.CurrentWhiteList;
        }
Exemplo n.º 7
0
 public TurniejWindowVM(List <string> listaGraczy, List <Film> listaFilmow)
 {
     _lista = new TrulyObservableCollection <FilmTurniej>();
     foreach (Film film in listaFilmow)
     {
         _lista.Add(new FilmTurniej(film));
     }
     ListaGraczy            = listaGraczy;
     indeksAktualnegoGracza = random.Next(listaGraczy.Count);
 }
Exemplo n.º 8
0
        /// <summary>
        /// Saves the rule config when changes are made
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RulesChangedHandler(object sender, NotifyCollectionChangedEventArgs e)
        {
            var collection    = new TrulyObservableCollection <MatchingRule>();
            var filteredRules = this._rules.Where(r => !string.IsNullOrEmpty(r.Pattern));//we don't want to save empty patterns!

            foreach (var filteredRule in filteredRules)
            {
                collection.Add(filteredRule);
            }

            Properties.Settings.Default.Rules = collection;
            Properties.Settings.Default.Save();
        }
Exemplo n.º 9
0
 private void initStatistics()
 {
     _statistic = new Statistics();
     Info       = new TrulyObservableCollection <InfoRow>();
     Info.Add(_infoDeviceName);
     Info.Add(_infoRightHand);
     Info.Add(_infoLeftHand);
     Info.Add(_infoSpine);
     Info.Add(_infoIsSkeletonDetected);
     Info.Add(_infoFramesPerSecond);
     Info.Add(_infoWastedFrames);
 }
 private void initStatistics()
 {
     _statistic = new Statistics();
     Info = new TrulyObservableCollection<InfoRow>();
     Info.Add(_infoDeviceName);
     Info.Add(_infoRightHand);
     Info.Add(_infoLeftHand);
     Info.Add(_infoSpine);
     Info.Add(_infoIsSkeletonDetected);
     Info.Add(_infoFramesPerSecond);
     Info.Add(_infoWastedFrames);
 }
Exemplo n.º 11
0
 public void Add(string id, Client newClient)
 {
     if (List.ContainsKey(id))
     {
         App.Current?.Dispatcher.Invoke((Action) delegate
         {
             List[id].Name = newClient.Name;
             List[id].ConfirmPresence(newClient.IP);
         });
     }
     else
     {
         App.Current?.Dispatcher.Invoke((Action) delegate
         {
             List.Add(id, newClient);
             ScreenList.Add(newClient);
             Project.Project.Current.Groups.AddClient(newClient);
         });
     }
 }
Exemplo n.º 12
0
        public TransactionTypesViewModel(IQueryDispatcher queryDispatcher, ICommandDispatcher commandDispatcher)
        {
            _commandDispatcher = commandDispatcher;

            var query            = new TransactionTypesQuery();
            var types            = queryDispatcher.Execute <TransactionTypesQuery, DtoType[]>(query);
            var transactionTypes = Mapper.Map <TransactionType[]>(types);

            TransactionTypes = new TrulyObservableCollection <TransactionType>(transactionTypes);
            TransactionTypes.CollectionChanged += TransactionTypesOnCollectionChanged;

            AddTransactionTypeCommand = new RelayCommand(() => { TransactionTypes.Add(new TransactionType {
                    Outcome = true
                }); });
            RemoveCommand = new RelayCommand <TransactionType>(x =>
            {
                _commandDispatcher.Execute(new DeleteTransactionTypeCommand(Mapper.Map <DtoType>(x)));
                TransactionTypes.Remove(x);
            });
        }
Exemplo n.º 13
0
        public void ShouldRaiseEventWhenItemIsAddedRemovedOrEdited()
        {
            var eventRaised = false;

            var collection = new TrulyObservableCollection <MockNotifiable>();

            collection.CollectionChanged += (s, e) => eventRaised = true;

            eventRaised = false;
            collection.Add(new MockNotifiable());
            Assert.That(eventRaised, Is.True);

            eventRaised = false;
            // The collection is supposed to raise the event if the property of one inner element is modified
            // This is the only added feature to the genuine ObservableCollection<>
            collection.First().Property = 100;
            Assert.That(eventRaised, Is.True);

            eventRaised = false;
            collection.RemoveAt(0);
            Assert.That(eventRaised, Is.True);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Constructeur avec paramètre.
        /// </summary>
        /// <param name="numero">Numero du local Ex: "D125"</param>
        /// <param name="nbPoste">nombre de postes dans le local</param>
        public Local(string numero, int nbPoste)
        {
            var task = LamaBD.helper.PosteHelper.SelectAllByNumeroLocalAsync(numero);

            task.Wait();

            NbPoste           = nbPoste;
            NbPoste_Depart    = nbPoste;
            Numero            = numero;
            LstPoste          = new TrulyObservableCollection <Poste>();
            VolontaireAssigne = new Volontaire();

            var listPostes = task.Result;

            for (int i = 1; i <= nbPoste; i++)
            {
                var poste = listPostes.FirstOrDefault(x => x.numeroPoste == i);
                LstPoste.Add(new Poste(i, poste.etatspostes.nom, poste.commentaire));
            }

            LstPoste.ItemPropertyChanged += PropertyChangedHandler;
        }
Exemplo n.º 15
0
        private void ShowTournamentNames()
        {
            if (ShowAllTournamentNames)
            {
                TournamentNames = _allTournamentNames;
            }
            else
            {
                TournamentNames = new TrulyObservableCollection<TournamentName>();

                foreach (var tournamentName in _allTournamentNames)
                {
                    if (tournamentName.StartDate.AddMonths(3) > DateTime.Now)
                    {
                        TournamentNames.Add(tournamentName);
                    }
                }
            }
        }
Exemplo n.º 16
0
        /*
        public void DoDynamicAnimation(object sender, MouseButtonEventArgs args)
        {
            for (var i = 0; i < 36; ++i)
            {
                // var e = new Button { Width = 50, Height = 16, Content="Test" };

                //var e = new Ellipse { Width = 16, Height = 16, Fill = SystemColors.HighlightBrush };
                //var e = new Ellipse { Width = 6, Height = 6, Fill=Brushes.HotPink };

                var e = new SliderNode(this) {Left = Mouse.GetPosition(this).X, Top = Mouse.GetPosition(this).Y};

                // var e = new TextBlock { Text = "Test" };
                // var e = new Slider { Width = 100 };

                // var e = new ProgressBar { Width = 100 , Height =10, Value=i };

                // var e = =new DataGrid{Width=100, Height=100};
                // var e = new TextBox { Text = "Hallo" };
                // var e = new Label { Content = "Halllo" };
                // var e = new RadioButton { Content="dfsdf" };

                //Canvas.SetLeft(e, Mouse.GetPosition(this).X);
                //Canvas.SetTop(e, Mouse.GetPosition(this).Y);

                var tg = new TransformGroup();
                var translation = new TranslateTransform(30, 0);
                var translationName = "myTranslation" + translation.GetHashCode();
                RegisterName(translationName, translation);
                tg.Children.Add(translation);
                tg.Children.Add(new RotateTransform(i*10));
                e.RenderTransform = tg;

                NodeCollection.Add(e);
                Children.Add(e);

                var anim = new DoubleAnimation(3, 250, new Duration(new TimeSpan(0, 0, 0, 2, 0)))
                {
                    EasingFunction = new PowerEase {EasingMode = EasingMode.EaseOut}
                };

                var s = new Storyboard();
                Storyboard.SetTargetName(s, translationName);
                Storyboard.SetTargetProperty(s, new PropertyPath(TranslateTransform.YProperty));
                var storyboardName = "s" + s.GetHashCode();
                Resources.Add(storyboardName, s);

                s.Children.Add(anim);

                s.Completed +=
                    (sndr, evtArgs) =>
                    {
                        //panel.Children.Remove(e);
                        Resources.Remove(storyboardName);
                        UnregisterName(translationName);
                    };
                s.Begin();
            }
        }
        */


        public void VplControl_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Key.Delete:

                    foreach (var node in SelectedNodes)
                        node.Delete();

                    foreach (var conn in SelectedConnectors)
                    {
                        conn.Delete();
                    }

                    SelectedNodes.Clear();
                    SelectedConnectors.Clear();
                    break;
                case Key.C:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                    {
                        tempCollection = new TrulyObservableCollection<Node>();


                        foreach (var node in SelectedNodes)
                            tempCollection.Add(node);
                    }
                }
                    break;
                case Key.V:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                    {
                        if (tempCollection == null) return;
                        if (tempCollection.Count == 0) return;

                        var bBox = Node.GetBoundingBoxOfNodes(tempCollection.ToList());

                        var copyPoint = new Point(bBox.Left + bBox.Size.Width/2, bBox.Top + bBox.Size.Height/2);
                        var pastePoint = Mouse.GetPosition(this);

                        var delta = Point.Subtract(pastePoint, copyPoint);

                        UnselectAllElements();

                        var alreadyClonedConnectors = new List<Connector>();
                        var copyConnections = new List<CopyConnection>();

                        // copy nodes from clipboard to canvas
                        foreach (var node in tempCollection)
                        {
                            var newNode = node.Clone();

                            newNode.Left += delta.X;
                            newNode.Top += delta.Y;

                            newNode.Left = Convert.ToInt32(newNode.Left);
                            newNode.Top = Convert.ToInt32(newNode.Top);

                            newNode.Show();

                            copyConnections.Add(new CopyConnection {NewNode = newNode, OldNode = node});

                        }

                        foreach (var cc in copyConnections)
                        {
                            var counter = 0;

                            foreach (var conn in cc.OldNode.InputPorts)
                            {
                                foreach (var connector in conn.ConnectedConnectors)
                                {
                                    if (!alreadyClonedConnectors.Contains(connector))
                                    {
                                        Connector newConnector = null;

                                        // start and end node are contained in selection
                                        if (tempCollection.Contains(connector.StartPort.ParentNode))
                                        {
                                            var cc2 =
                                                copyConnections.FirstOrDefault(
                                                    i => Equals(i.OldNode, connector.StartPort.ParentNode));

                                            if (cc2 != null)
                                            {
                                                newConnector = new Connector(this, cc2.NewNode.OutputPorts[0],
                                                    cc.NewNode.InputPorts[counter]);
                                            }
                                        }
                                        // only end node is contained in selection
                                        else
                                        {
                                            newConnector = new Connector(this, connector.StartPort,
                                                cc.NewNode.InputPorts[counter]);
                                        }

                                        if (newConnector != null)
                                        {
                                            alreadyClonedConnectors.Add(connector);
                                            ConnectorCollection.Add(newConnector);
                                        }
                                    }
                                }
                                counter++;
                            }
                        }
                    }
                }
                    break;
                case Key.G:
                {
                    if (Keyboard.Modifiers == ModifierKeys.Control)
                        GroupNodes();
                }
                    break;

                case Key.S:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                        SaveFile();
                }
                    break;
                case Key.T:
                {
                    Console.WriteLine("T");
                    foreach (var node in NodeCollection)
                    {
                        Console.WriteLine(node.ActualWidth);
                        Console.WriteLine(node.ActualHeight);
                    }
                }
                    break;
                case Key.O:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                        OpenFile();
                }
                    break;
                case Key.A:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                    {
                        SelectedNodes.Clear();

                        foreach (var node in NodeCollection)
                        {
                            node.IsSelected = true;
                            SelectedNodes.Add(node);
                        }
                    }
                }
                    break;
                case Key.Escape:
                {
                    UnselectAllElements();
                    mouseMode = MouseMode.Nothing;
                }
                    break;
                case Key.LeftCtrl:
                    if (!Keyboard.IsKeyDown(Key.RightCtrl)) ShowElementsAfterTransformation();
                    break;
                case Key.RightCtrl:
                    if (!Keyboard.IsKeyDown(Key.LeftCtrl)) ShowElementsAfterTransformation();
                    break;
            }
        }
        /// <summary>
        /// Saves the rule config when changes are made
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RulesChangedHandler(object sender, NotifyCollectionChangedEventArgs e)
        {
            var collection = new TrulyObservableCollection<MatchingRule>();
            var filteredRules = this._rules.Where(r => !string.IsNullOrEmpty(r.Pattern));//we don't want to save empty patterns!

            foreach (var filteredRule in filteredRules)
            {
                collection.Add(filteredRule);
            }

            Properties.Settings.Default.Rules = collection;
            Properties.Settings.Default.Save();
        }
Exemplo n.º 18
0
        /*
         * public void DoDynamicAnimation(object sender, MouseButtonEventArgs args)
         * {
         *  for (var i = 0; i < 36; ++i)
         *  {
         *      // var e = new Button { Width = 50, Height = 16, Content="Test" };
         *
         *      //var e = new Ellipse { Width = 16, Height = 16, Fill = SystemColors.HighlightBrush };
         *      //var e = new Ellipse { Width = 6, Height = 6, Fill=Brushes.HotPink };
         *
         *      var e = new SliderNode(this) {Left = Mouse.GetPosition(this).X, Top = Mouse.GetPosition(this).Y};
         *
         *      // var e = new TextBlock { Text = "Test" };
         *      // var e = new Slider { Width = 100 };
         *
         *      // var e = new ProgressBar { Width = 100 , Height =10, Value=i };
         *
         *      // var e = =new DataGrid{Width=100, Height=100};
         *      // var e = new TextBox { Text = "Hallo" };
         *      // var e = new Label { Content = "Halllo" };
         *      // var e = new RadioButton { Content="dfsdf" };
         *
         *      //Canvas.SetLeft(e, Mouse.GetPosition(this).X);
         *      //Canvas.SetTop(e, Mouse.GetPosition(this).Y);
         *
         *      var tg = new TransformGroup();
         *      var translation = new TranslateTransform(30, 0);
         *      var translationName = "myTranslation" + translation.GetHashCode();
         *      RegisterName(translationName, translation);
         *      tg.Children.Add(translation);
         *      tg.Children.Add(new RotateTransform(i*10));
         *      e.RenderTransform = tg;
         *
         *      NodeCollection.Add(e);
         *      Children.Add(e);
         *
         *      var anim = new DoubleAnimation(3, 250, new Duration(new TimeSpan(0, 0, 0, 2, 0)))
         *      {
         *          EasingFunction = new PowerEase {EasingMode = EasingMode.EaseOut}
         *      };
         *
         *      var s = new Storyboard();
         *      Storyboard.SetTargetName(s, translationName);
         *      Storyboard.SetTargetProperty(s, new PropertyPath(TranslateTransform.YProperty));
         *      var storyboardName = "s" + s.GetHashCode();
         *      Resources.Add(storyboardName, s);
         *
         *      s.Children.Add(anim);
         *
         *      s.Completed +=
         *          (sndr, evtArgs) =>
         *          {
         *              //panel.Children.Remove(e);
         *              Resources.Remove(storyboardName);
         *              UnregisterName(translationName);
         *          };
         *      s.Begin();
         *  }
         * }
         */


        public void VplControl_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.Delete:

                foreach (var node in SelectedNodes)
                {
                    node.Delete();
                }

                SelectedNodes.Clear();
                break;

            case Key.C:
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    tempCollection = new TrulyObservableCollection <Node>();


                    foreach (var node in SelectedNodes)
                    {
                        tempCollection.Add(node);
                    }
                }
            }
            break;

            case Key.V:
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    if (tempCollection == null)
                    {
                        return;
                    }
                    if (tempCollection.Count == 0)
                    {
                        return;
                    }

                    var bBox = Node.GetBoundingBoxOfNodes(tempCollection.ToList());

                    var copyPoint  = new Point(bBox.Left + bBox.Size.Width / 2, bBox.Top + bBox.Size.Height / 2);
                    var pastePoint = Mouse.GetPosition(this);

                    var delta = Point.Subtract(pastePoint, copyPoint);

                    SelectedNodes.Clear();

                    var alreadyClonedConnectors = new List <Connector>();
                    var copyConnections         = new List <CopyConnection>();

                    // copy nodes from clipboard to canvas
                    foreach (var node in tempCollection)
                    {
                        var newNode = node.Clone();

                        newNode.Left += delta.X;
                        newNode.Top  += delta.Y;

                        newNode.Left = Convert.ToInt32(newNode.Left);
                        newNode.Top  = Convert.ToInt32(newNode.Top);

                        NodeCollection.Add(newNode);

                        copyConnections.Add(new CopyConnection {
                                NewNode = newNode, OldNode = node
                            });
                    }

                    foreach (var cc in copyConnections)
                    {
                        var counter = 0;

                        foreach (var conn in cc.OldNode.InputPorts)
                        {
                            foreach (var connector in conn.ConnectedConnectors)
                            {
                                if (!alreadyClonedConnectors.Contains(connector))
                                {
                                    Connector newConnector = null;

                                    // start and end node are contained in selection
                                    if (tempCollection.Contains(connector.StartPort.ParentNode))
                                    {
                                        var cc2 =
                                            copyConnections.FirstOrDefault(
                                                i => Equals(i.OldNode, connector.StartPort.ParentNode));

                                        if (cc2 != null)
                                        {
                                            newConnector = new Connector(this, cc2.NewNode.OutputPorts[0],
                                                                         cc.NewNode.InputPorts[counter]);
                                        }
                                    }
                                    // only end node is contained in selection
                                    else
                                    {
                                        newConnector = new Connector(this, connector.StartPort,
                                                                     cc.NewNode.InputPorts[counter]);
                                    }

                                    if (newConnector != null)
                                    {
                                        alreadyClonedConnectors.Add(connector);
                                        ConnectorCollection.Add(newConnector);
                                    }
                                }
                            }
                            counter++;
                        }
                    }
                }
            }
            break;

            case Key.G:
            {
                if (Keyboard.Modifiers == ModifierKeys.Control)
                {
                    GroupNodes();
                }
            }
            break;

            case Key.S:
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    SaveFile();
                }
            }
            break;

            case Key.O:
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    OpenFile();
                }
            }
            break;

            case Key.A:
            {
                if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                {
                    SelectedNodes.Clear();

                    foreach (var node in NodeCollection)
                    {
                        node.IsSelected = true;
                        SelectedNodes.Add(node);
                    }
                }
            }
            break;
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Searches the directory and adds files to the File list
        /// </summary>
        /// <param name="folder">The starting folder</param>
        public void SearchDirectories(string folder, string workdir = "")
        {
            //Throws exception if no permissions
            try
            {
                nonAccessibleFiles = 0;
                _fileList.Clear();
                filesList.Clear();
                int  i    = 1;
                bool flag = false;

                ApplyAllFiles(folder, ProcessFile);
                string[] files = filesList.ToArray();

                foreach (string file in files)
                {
                    foreach (WhiteList wl in _currentWhiteList)
                    {
                        if (wl.Extension == Path.GetExtension(file))
                        {
                            if (Properties.Settings.Default.Setting_General_UseRelativePath)
                            {
                                string temp = MakeRelativePath(workdir + "\\", System.IO.Path.GetDirectoryName(file) + "\\");
                                temp += System.IO.Path.GetFileName(file);
                                _fileList.Add(new MyFile(System.IO.Path.GetFileNameWithoutExtension(file), temp, System.IO.Path.GetExtension(file), i));
                                i++;
                                flag = true;
                                break;
                            }
                            else
                            {
                                _fileList.Add(new MyFile(System.IO.Path.GetFileNameWithoutExtension(file), file, System.IO.Path.GetExtension(file), i));
                                i++;
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (flag)
                    {
                        continue;
                    }
                }

                if (nonAccessibleFiles != 0)
                {
                    NotifyMessage = "Some files were not accessible, restart as admin to get all files";
                    StatusText    = nonAccessibleFiles + "/" + (i - 1 + nonAccessibleFiles) + " Files could not be accessed";
                    FlyoutOpen    = true;
                }
                else
                {
                    StatusText = (i - 1) + " Files found";
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                string outputString;
                outputString = Environment.NewLine + "Exception caught" + Environment.NewLine + "Date: " + DateTime.UtcNow.Date.ToString("dd/MM/yyyy") + ", Time: " + DateTime.Now.ToString("HH:mm:ss tt") + Environment.NewLine + ex.Message + Environment.NewLine + ex.ToString() + Environment.NewLine;

                using (System.IO.StreamWriter file =
                           new System.IO.StreamWriter(assemblyPath + "\\CrashLog.txt", true))
                {
                    file.WriteLine(outputString);
                }

                outputString = null;

                NotifyMessage = "Unauthorized access, restart as Admin to gain access";
                FlyoutOpen    = true;
            }
            catch (Exception ex)
            {
                string outputString;
                outputString = Environment.NewLine + "Exception caught" + Environment.NewLine + "Date: " + DateTime.UtcNow.Date.ToString("dd/MM/yyyy") + ", Time: " + DateTime.Now.ToString("HH:mm:ss tt") + Environment.NewLine + ex.Message + Environment.NewLine + ex.ToString() + Environment.NewLine;

                using (System.IO.StreamWriter file =
                           new System.IO.StreamWriter(assemblyPath + "\\CrashLog.txt", true))
                {
                    file.WriteLine(outputString);
                }

                outputString = null;
            }
        }
Exemplo n.º 20
0
        private void CreateEmptyClosestToThePin()
        {
            ClosestToThePinsDay1 = new TrulyObservableCollection<ClosestToThePin>();
            ClosestToThePinsDay1.Add(new ClosestToThePin { Hole = 5 });
            ClosestToThePinsDay1.Add(new ClosestToThePin { Hole = 9 });
            ClosestToThePinsDay1.Add(new ClosestToThePin { Hole = 11 });
            ClosestToThePinsDay1.Add(new ClosestToThePin { Hole = 15 });

            ClosestToThePinsDay2 = new TrulyObservableCollection<ClosestToThePin>();
            ClosestToThePinsDay2.Add(new ClosestToThePin { Hole = 5 });
            ClosestToThePinsDay2.Add(new ClosestToThePin { Hole = 9 });
            ClosestToThePinsDay2.Add(new ClosestToThePin { Hole = 11 });
            ClosestToThePinsDay2.Add(new ClosestToThePin { Hole = 15 });
        }
Exemplo n.º 21
0
        protected void LoadTournamentNamesFromWebResponse(
            string webResponse, 
            TrulyObservableCollection<TournamentName> tournamentNames,
            bool loadAll)
        {
            tournamentNames.Clear();

            var jss = new JavaScriptSerializer();
            TournamentName[] names = jss.Deserialize<TournamentName[]>(webResponse);

            foreach (var tournamentName in names)
            {
                if (loadAll)
                {
                    tournamentNames.Add(tournamentName);
                }
                else if (tournamentName.StartDate.AddMonths(3) > DateTime.Now)
                {
                    tournamentNames.Add(tournamentName);
                }
            }

            OnTournamentsUpdated();
        }
Exemplo n.º 22
0
        protected void LoadTournamentDescriptionsFromWebResponse(string responseString,
            TrulyObservableCollection<TournamentDescription> tournamentDescriptionNames)
        {
            string[] lines = responseString.Split('\n');
            string[][] csvParsedLines = CSVParser.Parse(lines);

            bool clearedDescriptions = false;
            int lineNumber = 0;
            foreach (var fields in csvParsedLines)
            {
                lineNumber++;
                if ((fields.Length == 0) || string.IsNullOrWhiteSpace(fields[0])) continue;

                if (!clearedDescriptions)
                {
                    clearedDescriptions = true;
                    
                }

                if (fields.Length < 3)
                {
                    // the description contains newlines, so the line number doesn't match up ...
                    throw new ArgumentException(string.Format("Website response: line {0}: contains fewer than 3 fields: {1}", lineNumber, lines[lineNumber - 1]));
                }

                var td = new TournamentDescription();

                int key;
                if (!int.TryParse(fields[0], out key))
                {
                    throw new ArgumentException(string.Format("Website response: line {0}: contains a bad key: {1}", lineNumber, fields[0]));
                }
                td.TournamentDescriptionKey = key;
                td.Name = fields[1];
                td.Description = fields[2].Replace("\r\r", "\r");

                tournamentDescriptionNames.Add(td);
            }
        }
Exemplo n.º 23
0
        private async Task LoadSignupsFromWeb(object o)
        {
            if (TournamentNames.Count == 0)
            {
                MessageBox.Show("You must select a touranment first");
                return;
            }
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(WebAddresses.BaseAddress);

                using (new WaitCursor())
                {
                    var values = new List<KeyValuePair<string, string>>();

                    values.Add(new KeyValuePair<string, string>("tournament",
                        TournamentNames[TournamentNameIndex].TournamentKey.ToString(CultureInfo.InvariantCulture)));

                    var content = new FormUrlEncodedContent(values);

                    var response = await client.PostAsync(WebAddresses.ScriptFolder + WebAddresses.GetSignups, content);
                    var responseString = await response.Content.ReadAsStringAsync();

                    Logging.Log("LoadSignupsFromWeb", responseString);

                    TeeTimeRequests.Clear();
                    List<TeeTimeRequest> ttr = LoadSignupsFromWebResponse(responseString);

                    PaymentsDue = 0;
                    PaymentsMade = 0;
                    TrulyObservableCollection<TeeTimeRequest> ttr2 = new TrulyObservableCollection<TeeTimeRequest>();
                    foreach (var teeTimeRequest in ttr)
                    {
                        ttr2.Add(teeTimeRequest);
                        PaymentsDue += teeTimeRequest.PaymentDue;
                        PaymentsMade += teeTimeRequest.PaymentMade;
                    }
                    TeeTimeRequests = ttr2;
                    ttr2.CollectionChanged += TeeTimeRequests_CollectionChanged;
                }
            }
        }
Exemplo n.º 24
0
 public StyleDatabase(SettingsHelper helperArg)
 {
     Global.CallNew(out settings);
     foreach (var e in Enum.GetValues(typeof(FormatterSettingsScope)).Cast<FormatterSettingsScope> ())
         settings.Add(e, new FormatSettings());
     settingsHelper = helperArg;
     styles = new TrulyObservableCollection<StyleInfo>();
     foreach (ClangFormat.StyleId id in Enum.GetValues(typeof(ClangFormat.StyleId)))
         styles.Add(new PredefinedStyleInfo(id));
     styles.Add(new FileStyleInfo());
     customViewSource = new CollectionViewSource { Source = styles };
     customViewSource.View.Filter = p => p is CustomStyleInfo;
     allViewSource = new CollectionViewSource { Source = styles };
     loadSettings();
 }
Exemplo n.º 25
0
        private void btnParseAmazonCode_Click(object sender, RoutedEventArgs e)
        {
            //string regex = @"USD ([$\d\.]*)[\s]*Amazon.com Gift Card claim code: ([\d\w\-]*)";
            string          regex   = @"\$([\d\.]*).([\w\d]{4}-[\w\d]{6}-[\w\d]{4})";
            MatchCollection matches = Regex.Matches(txtUnparsedAmazonCodes.Text, regex);
            bool            noValue = false;

            if (matches.Count < 1)
            {
                regex   = @"([\w\d]{4}-[\w\d]{6}-[\w\d]{4})";
                matches = Regex.Matches(txtUnparsedAmazonCodes.Text, regex);
                noValue = true;
            }

            StringBuilder sb = new StringBuilder();

            colParsedAmazonGiftCodes.Clear();
            int codeCount = 0;

            foreach (Match m in matches)
            {
                codeCount++;
                if (noValue)
                {
                    colParsedAmazonGiftCodes.Add(new AmazonGiftCode(codeCount, m.Groups[1].Value, null));
                }
                else
                {
                    colParsedAmazonGiftCodes.Add(new AmazonGiftCode(codeCount, m.Groups[2].Value, decimal.Parse(m.Groups[1].Value)));
                }
            }

            if (colParsedAmazonGiftCodes.Count < 1)
            {
                txtUnparsedAmazonCodes.Background = System.Windows.Media.Brushes.Pink;
            }
            else
            {
                txtExpectedValue.Text = colParsedAmazonGiftCodes.Sum(p => p.Value).ToString();

                if (txtExpectedValue.Text == String.Empty)
                {
                    txtExpectedValue.Background = System.Windows.Media.Brushes.Pink;
                }
                else
                {
                    var listDuplicateGiftCodes = colParsedAmazonGiftCodes.GroupBy(p => p.Code).Where(g => g.Count() > 1).Select(p => p.Key).ToList();


                    if (listDuplicateGiftCodes.Count > 0)
                    {
                        sb = new StringBuilder();
                        sb.AppendLine("Duplicate gift codes detected!");

                        foreach (var gc in listDuplicateGiftCodes)
                        {
                            sb.AppendLine(gc);
                        }

                        MessageBox.Show(sb.ToString());
                    }


                    decimal expectedValue = 0;
                    decimal.TryParse(txtExpectedValue.Text, out expectedValue);
                    if (expectedValue > 0)
                    {
                        txtExpectedValue.Background = System.Windows.Media.Brushes.White;
                    }
                    else
                    {
                        txtExpectedValue.Background = System.Windows.Media.Brushes.Pink;
                    }
                }

                txtUnparsedAmazonCodes.Background = System.Windows.Media.Brushes.White;
            }
            //txtExpectedValue.Focus();
            //txtExpectedValue.SelectAll();
        }
Exemplo n.º 26
0
        /*
        public void DoDynamicAnimation(object sender, MouseButtonEventArgs args)
        {
            for (var i = 0; i < 36; ++i)
            {
                // var e = new Button { Width = 50, Height = 16, Content="Test" };

                //var e = new Ellipse { Width = 16, Height = 16, Fill = SystemColors.HighlightBrush };
                //var e = new Ellipse { Width = 6, Height = 6, Fill=Brushes.HotPink };

                var e = new SliderNode(this) {Left = Mouse.GetPosition(this).X, Top = Mouse.GetPosition(this).Y};

                // var e = new TextBlock { Text = "Test" };
                // var e = new Slider { Width = 100 };

                // var e = new ProgressBar { Width = 100 , Height =10, Value=i };

                // var e = =new DataGrid{Width=100, Height=100};
                // var e = new TextBox { Text = "Hallo" };
                // var e = new Label { Content = "Halllo" };
                // var e = new RadioButton { Content="dfsdf" };

                //Canvas.SetLeft(e, Mouse.GetPosition(this).X);
                //Canvas.SetTop(e, Mouse.GetPosition(this).Y);

                var tg = new TransformGroup();
                var translation = new TranslateTransform(30, 0);
                var translationName = "myTranslation" + translation.GetHashCode();
                RegisterName(translationName, translation);
                tg.Children.Add(translation);
                tg.Children.Add(new RotateTransform(i*10));
                e.RenderTransform = tg;

                NodeCollection.Add(e);
                Children.Add(e);

                var anim = new DoubleAnimation(3, 250, new Duration(new TimeSpan(0, 0, 0, 2, 0)))
                {
                    EasingFunction = new PowerEase {EasingMode = EasingMode.EaseOut}
                };

                var s = new Storyboard();
                Storyboard.SetTargetName(s, translationName);
                Storyboard.SetTargetProperty(s, new PropertyPath(TranslateTransform.YProperty));
                var storyboardName = "s" + s.GetHashCode();
                Resources.Add(storyboardName, s);

                s.Children.Add(anim);

                s.Completed +=
                    (sndr, evtArgs) =>
                    {
                        //panel.Children.Remove(e);
                        Resources.Remove(storyboardName);
                        UnregisterName(translationName);
                    };
                s.Begin();
            }
        }
        */


        public void VplControl_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
                case Key.Delete:

                    // Do not Delete if there is an ScriptingNode in the selection -> Delete Key is used several times inside ... 
                    foreach (var node in SelectedNodes)
                    {
                        if (node.GetType().ToString() == "TUM.CMS.VPL.Scripting.Nodes.ScriptingNode")
                            return;
                        node.Delete();
                    }
                        

                    SelectedNodes.Clear();
                    break;
                case Key.C:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                    {
                        tempCollection = new TrulyObservableCollection<Node>();


                        foreach (var node in SelectedNodes)
                            tempCollection.Add(node);
                    }
                }
                    break;
                case Key.V:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                    {
                        // Do not copy if there is an ScriptingNode in the selection
                        if (SelectedNodes.Any(node => node.GetType().ToString() == "TUM.CMS.VPL.Scripting.Nodes.ScriptingNode"))
                        {
                            return;
                        }

                        if (tempCollection == null) return;
                        if (tempCollection.Count == 0) return;

                        var bBox = Node.GetBoundingBoxOfNodes(tempCollection.ToList());

                        var copyPoint = new Point(bBox.Left + bBox.Size.Width/2, bBox.Top + bBox.Size.Height/2);
                        var pastePoint = Mouse.GetPosition(this);

                        var delta = Point.Subtract(pastePoint, copyPoint);

                        SelectedNodes.Clear();

                        var alreadyClonedConnectors = new List<Connector>();
                        var copyConnections = new List<CopyConnection>();

                        // copy nodes from clipboard to canvas
                        foreach (var node in tempCollection)
                        {
                            var newNode = node.Clone();

                            newNode.Left += delta.X;
                            newNode.Top += delta.Y;

                            newNode.Left = Convert.ToInt32(newNode.Left);
                            newNode.Top = Convert.ToInt32(newNode.Top);

                            NodeCollection.Add(newNode);

                            copyConnections.Add(new CopyConnection {NewNode = newNode, OldNode = node});
                        }

                        foreach (var cc in copyConnections)
                        {
                            var counter = 0;

                            foreach (var conn in cc.OldNode.InputPorts)
                            {
                                foreach (var connector in conn.ConnectedConnectors)
                                {
                                    if (!alreadyClonedConnectors.Contains(connector))
                                    {
                                        Connector newConnector = null;

                                        // start and end node are contained in selection
                                        if (tempCollection.Contains(connector.StartPort.ParentNode))
                                        {
                                            var cc2 =
                                                copyConnections.FirstOrDefault(
                                                    i => Equals(i.OldNode, connector.StartPort.ParentNode));

                                            if (cc2 != null)
                                            {
                                                newConnector = new Connector(this, cc2.NewNode.OutputPorts[0],
                                                    cc.NewNode.InputPorts[counter]);
                                            }
                                        }
                                        // only end node is contained in selection
                                        else
                                        {
                                            newConnector = new Connector(this, connector.StartPort,
                                                cc.NewNode.InputPorts[counter]);
                                        }

                                        if (newConnector != null)
                                        {
                                            alreadyClonedConnectors.Add(connector);
                                            ConnectorCollection.Add(newConnector);
                                        }
                                    }
                                }
                                counter++;
                            }
                        }
                    }
                }
                    break;
                case Key.G:
                {
                    if (Keyboard.Modifiers == ModifierKeys.Control)
                        GroupNodes();
                }
                    break;
                case Key.S:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                        SaveFile();
                }
                    break;
                case Key.O:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                        OpenFile();
                }
                    break;
                case Key.A:
                {
                    if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl))
                    {
                        SelectedNodes.Clear();

                        foreach (var node in NodeCollection)
                        {
                            node.IsSelected = true;
                            SelectedNodes.Add(node);
                        }
                    }
                }
                    break;
            }
        }