/// <summary> /// 加载 /// </summary> private void Load(string filePath) { try { if (!string.IsNullOrWhiteSpace(curOpenFile) && !string.IsNullOrWhiteSpace(filePath)) { if (MessageBoxResult.OK != MessageBox.Show("存在未保存的项目,是否继续加载?", "警告", MessageBoxButton.OKCancel)) { return; } } canvasMain.Children.Clear(); curOpenFile = filePath; string watchface = curOpenFile + "/watchface"; string watch_face_config = watchface + "/watch_face_config.xml"; string res = watchface + "/res/"; ConfigReader reader = new ConfigReader(watch_face_config, res); watchElements.Clear(); List <HWElement> elementList = reader.Read(); radio454.IsChecked = (reader.Resolution == 0); ClockDialCreater creater = new ClockDialCreater(elementList, canvasMain); var watchs = creater.Creater(); for (int i = 0; i < watchs.Count; i++) { watchElements.Add(watchs[i]); } } catch (Exception e) { MessageBox.Show(e.Message); } }
/// <summary> /// 创建一个元素 /// </summary> /// <param name="hWElement"></param> /// <param name="canvas"></param> /// <param name="resPath"></param> /// <returns></returns> public static WatchElement CreaterElement(HWElement hWElement, Canvas canvas, string resPath) { ClockDialCreater clockDialCreater = new ClockDialCreater(new List <HWElement> { hWElement }, canvas); ObservableCollection <WatchElement> watchs = clockDialCreater.Creater(); return((watchs == null || watchs.Count == 0) ? null : watchs[0]); }
/// <summary> /// 添加元素 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnAdd_Click(object sender, RoutedEventArgs e) { AddElementWindow add = new AddElementWindow(resolution); if (add.ShowDialog() ?? false) { WatchElement element = ClockDialCreater.CreaterElement(add.HWElement, canvasMain, curOpenFile); watchElements.Add(element); } }