public QuoteEmojiAnalizer([NotNull] Regex regex,
                           [NotNull] Dictionary <string, string> emojiPaths)
 {
     Asure.NotNull(regex, emojiPaths);
     _regex      = regex;
     _emojiPaths = emojiPaths;
 }
예제 #2
0
        public SelectGirlWindow([NotNull] IEnumerable <Girl> girls,
                                [NotNull] Action <Girl> callback)
        {
            Asure.NotNull(girls, callback);
            _callback = callback;

            InitializeComponent();
            var children = this.girlsPanel.Children;
            var tiles    = girls.Select(g =>
            {
                var bitmap = Api.Api.CreateImageFromPath(g.Path);
                // set girl as id for tile so that we know which was clicked
                var tile = new TitledTile(g)
                {
                    Title     = g.Name,
                    TileImage = bitmap
                };
                tile.Click += OnGirlTileClicked;
                return(tile);
            });

            foreach (var tile in tiles)
            {
                children.Add(tile);
            }

            Show();
        }
예제 #3
0
        private void QuoteLocation_Click(object sender, RoutedEventArgs e)
        {
            var tag = (sender as MenuItem).Tag;

            Asure.NotNull(tag);

            this.quoteField.VerticalAlignment = (VerticalAlignment)tag;
        }
예제 #4
0
        private string GetNextQuote()
        {
            var limit = _quotes.Count;
            var next  = (_quoteRandomizer.Next() & int.MaxValue) % limit;

            Asure.CantBe(next < 0 && next >= limit);
            return(_quotes[next]);
        }
예제 #5
0
 public GirlQuoteProvider([NotNull] IList <string> quotes,
                          [NotNull] IQuoteAnalizer quoteAnalizer)
 {
     Asure.NotNull(quotes, quoteAnalizer);
     _quotes          = quotes;
     _analizer        = quoteAnalizer;
     _quoteRandomizer = new Random();
 }
예제 #6
0
        public void SetGirl([NotNull] Girl girl)
        {
            Asure.NotNull(girl, girl.Path, girl.Name, girl.Quotes);

            QuoteShown = false;
            BitmapImage image = Api.Api.CreateImageFromPath(girl.Path);

            this.girlImage.Source  = image;
            this.girlImage.ToolTip = girl.Name;
        }
예제 #7
0
        public void ProvideQuote([NotNull] InlineCollection inlines)
        {
            Asure.NotNull(inlines);

            inlines.Clear();
            var quote = GetNextQuote();

            _analizer.Analize(quote);
            _analizer.ProcessAndStyle(inlines);
        }
예제 #8
0
        public static BitmapImage CreateImageFromPath([NotNull] string path)
        {
            Asure.NotNull(path);

            var bitmap = new BitmapImage();

            bitmap.BeginInit();
            bitmap.UriSource = new Uri(Path.GetFullPath(path));
            bitmap.EndInit();
            return(bitmap);
        }
예제 #9
0
        public AddGirlWindow([NotNull] Action <Girl> callback)
        {
            Asure.NotNull(callback);
            _callback = callback;

            this.DataContext = this;
            addQuoteButton_Click(null, null);
            InitializeComponent();
            confirmButton.IsEnabled = false;
            Show();
        }
예제 #10
0
        public void SetGirl([NotNull] Girl girl)
        {
            Asure.NotNull(girl);
            _mainWindow.SetGirl(girl);
            _mainWindow.QuoteProvider = new GirlQuoteProvider(girl.Quotes,
                                                              _emojiConfig.GetQuoteAnalizer());

            if (_visible == false)
            {
                _mainWindow.Show();
                _visible = true;
            }
        }
예제 #11
0
 public QuoteEmojiConfig()
 {
     if (_config == null)
     {
         using (var reader = new StreamReader(ConfigFileName))
         {
             _config = Deserializer.Consume <List <Emoji> >(reader, ModelMembers.Property);
             Asure.NotNull(_config);
         }
     }
     NormalizeCodes();
     BuildPathsLookup();
     BuildAnalizer();
 }
예제 #12
0
        public void Show(bool show)
        {
            Asure.CantBe(show == _visible);

            if (show)
            {
                _mainWindow.Show();
            }
            else
            {
                _mainWindow.Hide();
            }

            _visible = show;
        }
예제 #13
0
        private void girlImage_MouseDown(object sender, MouseButtonEventArgs e)
        {
            QuoteShown = e.ChangedButton == MouseButton.Left || _quoteShown;

            if (e.ChangedButton == MouseButton.Left)
            {
                _quoteProvider.ProvideQuote(this.quoteField.Inlines);
            }
            else if (_quoteShown)
            {
                this.ContextMenu = this.FindResource("contextMenu") as ContextMenu;
                Asure.NotNull(this.ContextMenu);

                this.ContextMenu.PlacementTarget = sender as UIElement;
                this.ContextMenu.IsOpen          = true;
            }
        }
예제 #14
0
        public GirlsConfig()
        {
            if (!File.Exists(ConfigFileName))
            {
                WriteDefaultConfig();
            }

            if (!Directory.Exists(GirlsFolder))
            {
                CreateDefaultGirl();
            }

            if (_config == null)
            {
                using (var reader = new StreamReader(ConfigFileName))
                {
                    _config = Deserializer.Consume <Config>(reader, ModelMembers.Property);
                    Asure.NotNull(_config);
                }
            }
        }