我是看到这篇公告:CSDN博客频道支持Windows Live Writer离线写博客啦,觉得不错然后尝试一下,挺不错的。

写好了先保存为本地草稿然后等有机会接入网络时再发布。这是一个测试页面,放上几张图片试试效果

Windows Live Writer 离线写博客测试

真心不错,记录一下。

新增加了几个插件,续测试,插入代码片段


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Visifire.Charts;

namespace AliChart.Pages
{
    /// <summary>
    /// Interaction logic for SoldFlow.xaml
    /// </summary>
    public partial class SoldFlow : UserControl
    {
        private DataModel<StatIntList> dataModel;
        private List<int> indexList = new List<int>();
        private int lineCount = 0;
        private string suffix;
        public SoldFlow()
        {
            InitializeComponent();
            DataModel<StatIntList> dataModel = SharedData.dmc.WeeklySold();
            foreach (var obj in dataModel.data)
            {
                ItemList.Items.Add(obj.Name);
            }
        }

        public Chart CreateChartLine(string name)
        {
            Chart chart = new Chart();
            chart.Height = 450;
            chart.Margin = new Thickness(0, 0, 0, 0);
            chart.View3D = false;
            Axis yAxis = new Axis();
            yAxis.AxisMinimum = 0;
            chart.AxesY.Add(yAxis);
            Title title = new Title();
            title.Text = name;
            title.Padding = new Thickness(0, 5, 5, 0);
            chart.Titles.Add(title);

            int valueCount = dataModel.data[0].Value.Count;

            int w = valueCount * 40;
            if (w < 600) w = 600;
            chart.Width = w;
           
            int idx = 0;
            for (int i = 0; i < lineCount;++i)
            {
                idx = indexList[i];
                DataSeries dataSeries = new DataSeries();
                dataSeries.RenderAs = RenderAs.Line;
                dataSeries.LineThickness = 2.0;
                dataSeries.LegendText = dataModel.data[idx].Name;
                for (int j = 0; j < valueCount; ++j)
                {
                    DataPoint dataPoint = new DataPoint();
                    dataPoint.AxisXLabel = "#" + (j + 1).ToString();
                    dataPoint.YValue = dataModel.data[idx].Value[j];
                   dataSeries.DataPoints.Add(dataPoint);
                }
                chart.Series.Add(dataSeries);
                chart.Rendered += new EventHandler(chart_Rendered); //去掉多重水印
            }

            return chart;
        }

        //去水印
        void chart_Rendered(object sender, EventArgs e)
        {
            var c = sender as Chart;
            var legend = c.Legends[0];
            var root = legend.Parent as Grid;
            root.Children.RemoveAt(10);
            root.Children.RemoveAt(9);
            //var stackPanel=root.Children[10] as StackPanel;  
            //var textBlock1 = stackPanel.Children[0] as TextBlock;  
            //textBlock1.Text = "http://blog.csdn.net/fengyhack";
            //var border = root.Children[9] as Border;
            //var textBlock2 = border.Child as TextBlock;
            //textBlock2.Text = "http://blog.csdn.net/fengyhack";         
        }

        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            if (rb07.IsChecked == true)
            {
                dataModel = SharedData.dmc.WeeklySold();
                suffix = "(间隔:7天)";
            }
            else if (rb15.IsChecked == true)
            {
                dataModel = SharedData.dmc.HonthlySold();
                suffix = "(间隔:15天)";
            }
            else
            {
                dataModel = SharedData.dmc.MonthlySold();
                suffix = "(间隔:30天)";
            }
            lineCount = 0;
            foreach (var obj in ItemList.SelectedItems)
            {
                string str = obj as string;
                int idx = ItemList.Items.IndexOf(obj);
                if (idx >= 0)
                {
                    indexList.Add(idx);
                    ++lineCount;
                }
            }
            if (lineCount == 0) return;
            GridSoldFlow.Children.Clear();
            Chart chart = CreateChartLine("销量走势"+suffix);
            GridSoldFlow.Children.Add(chart);
        }

        private void ItemList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {

        }
    }
}

相关文章: