private void 保存ToolStripMenuItem_Click_1(object sender, EventArgs e) { if (focusSettingFileName == null) { 另存为ToolStripMenuItem_Click(sender, e); return; } SettingModel.Save(list.List, focusSettingFileName, focusSettingFileName.Substring(focusSettingFileName.LastIndexOf('.') + 1), canvas); }
private void 读取ToolStripMenuItem_Click(object sender, EventArgs e) { var f = new OpenFileDialog() { Title = "读取布局", Filter = "卡片模板|*.cm;*.cmx;*.cmm|所有文件|*.*" }; if (f.ShowDialog() == DialogResult.OK) { list.Clear(); canvas.List.Clear(); var l = SettingModel.Load(f.FileName, out string bg, out int w, out int h); //TODO 输入文件 if (bg.Length > 0) { SettingModel.BackGroundImg = bg; } canvas.OnSizeModefy(w, h); if (l == null) { return; } foreach (var i in l) { var c = new Element(i) { OnCtlSelected = (ctl, mutiSelect) => { if (ctl != null && !ctl.Selected) { selectedCtl.Add(ctl); ctl.MoveConfirm(); ctl.Selected = true; } } }; i.OnSettingModify = (setting) => { c.RefreshAnySetting(); }; canvas.List.Add(c); list.New(i, false); } switch (f.FileName.Substring(f.FileName.LastIndexOf('.') + 1)) { case "cmx": { BgImage = SettingModel.Image; break; } } canvasNeedRefresh = true; } }
private void 另存为ToolStripMenuItem_Click(object sender, EventArgs e) { var f = new SaveFileDialog() { Title = "保存当前布局", Filter = "卡片模板|*.cmx" }; if (f.ShowDialog() == DialogResult.OK) { SettingModel.Save(list.List, f.FileName, f.FileName.Substring(f.FileName.LastIndexOf('.') + 1), canvas); } }
private void LoadSetting(string path) { if (CheckNowFileModefied()) { return; } focusSettingFileName = path; list.Clear(); canvas.List.Clear(); var l = SettingModel.Load(path); //TODO 输入文件 if (l == null) { return; } canvas.SetBckImage(l.Canvas.bckImagePath); foreach (var i in l.Content) { var c = new Element(i) { OnCtlSelected = (ctl, mutiSelect) => { if (ctl != null && !ctl.Selected) { selectedCtl.Add(ctl); ctl.MoveConfirm(); ctl.Selected = true; } } }; i.OnSettingModify = (setting) => { c.RefreshAnySetting(); }; canvas.List.Add(c); list.New(i, false); } canvasNeedRefresh = true; }