/// <summary>
        /// add new post
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void NewPost(object sender, RoutedEventArgs e)
        {
            // todo : check config
            // there already a temp post
            if (FindTempFile())
            {
                return;
            }

            var current = new PostItemControl(this.inputTbx);

            current.Register((sender, e) =>
            {
                foreach (var control in cacheControls)
                {
                    control.Background = new SolidColorBrush(Color.FromRgb(49, 47, 47));
                    control.Foreground = new SolidColorBrush(Colors.Silver);
                    control.RemoveHandlers();
                }

                current.Background = new SolidColorBrush(Color.FromRgb(199, 80, 73));
                current.Foreground = new SolidColorBrush(Colors.White);
                selectedItem       = current;
                current.ConfigTimer();
            });
            inputTbx.Text =
                $"---{Environment.NewLine}{Environment.NewLine}title: {Environment.NewLine}{Environment.NewLine}date: {DateTime.Now.ToString(TimePattern)}{Environment.NewLine}{Environment.NewLine}tags: {Environment.NewLine}{Environment.NewLine}---{Environment.NewLine}{Environment.NewLine}";
            markdownPreview.Markdown =
                $"---{Environment.NewLine}{Environment.NewLine}title: {Environment.NewLine}{Environment.NewLine}date: {DateTime.Now.ToString(TimePattern)}{Environment.NewLine}{Environment.NewLine}tags: {Environment.NewLine}{Environment.NewLine}---{Environment.NewLine}{Environment.NewLine}";
            current.UpdateCache();
            articleListPanel.Children.Insert(0, current);
            cacheControls.Add(current);
            SelectControl(current);
        }
        /// <summary>
        /// load post or reload posts
        /// </summary>
        private void LoadPosts()
        {
            // make sure directory exists
            GitUtils.MakeDirectory(CommonData.config.PostDirectory);
            // clear selected
            if (selectedItem != null)
            {
                selectedItem.RemoveHandlers();
                selectedItem = null;
            }

            inputTbx.Text = string.Empty;
            articleListPanel.Children.Clear();

            // get markdown files
            var files = Directory.GetFiles(CommonData.config.PostDirectory)
                        .Where(f => f.EndsWith(Suffix));

            var targetBackground = new SolidColorBrush(Color.FromRgb(199, 80, 73));
            var targetForeground = new SolidColorBrush(Colors.White);
            var otherBackground  = new SolidColorBrush(Color.FromRgb(49, 47, 47));
            var otherForeground  = new SolidColorBrush(Colors.Silver);

            // deal with each post
            foreach (var file in files)
            {
                var current = new PostItemControl(file, this.inputTbx);
                current.Register((sender, e) =>
                {
                    foreach (var control in cacheControls)
                    {
                        control.Background = otherBackground;
                        control.Foreground = otherForeground;
                        control.RemoveHandlers();
                    }
                    // current
                    current.Background = targetBackground;
                    current.Foreground = targetForeground;
                    selectedItem       = current;
                    current.ConfigTimer();
                });
                articleListPanel.Children.Add(current);
            }

            // bake in cache
            var array = new PostItemControl[articleListPanel.Children.Count];

            articleListPanel.Children.CopyTo(array, 0);
            // add cache
            cacheControls.Clear();
            cacheControls.AddRange(array);
        }
 /// <summary>
 /// remove post item in panel
 /// </summary>
 private void RemoveItemInPanel()
 {
     // remove event handler
     selectedItem.RemoveHandlers();
     // remove
     articleListPanel.Children.Remove(selectedItem);
     // remove cache
     cacheControls.TryRemove(selectedItem);
     // remove selected
     selectedItem = null;
     // clear input text box
     inputTbx.Text = string.Empty;
 }
        /// <summary>
        /// enable some item selected
        /// </summary>
        /// <param name="target"></param>
        private void SelectControl(PostItemControl target)
        {
            var targetBackground = new SolidColorBrush(Color.FromRgb(199, 80, 73));
            var targetForeground = new SolidColorBrush(Colors.White);
            var otherBackground  = new SolidColorBrush(Color.FromRgb(49, 47, 47));
            var otherForeground  = new SolidColorBrush(Colors.Silver);

            foreach (var control in cacheControls)
            {
                control.RemoveHandlers();
                if (control == target)
                {
                    control.Background = targetBackground;
                    control.Foreground = targetForeground;
                    selectedItem       = control;
                    control.ConfigTimer();
                }
                else
                {
                    control.Background = otherBackground;
                    control.Foreground = otherForeground;
                }
            }
        }