public void AcceptChangesTest3() { SignGroupInfo[] group = new SignGroupInfo[14]; for (int i = 0; i < group.Length; i++) { group[i] = new SignGroupInfo(); group[i].Name = "group" + i; SignInfo newsign = new SignInfo(); newsign.Name = "sing" + i; if (i == 0) { group[i].Parent = tree; } else { group[i].Parent = group[i - 1]; newsign.Parent = group[i]; } } Assert.AreEqual(true, tree.IsChanged); tree.AcceptChanges(); Assert.AreEqual(false, tree.IsChanged); }
private MemoryDataProvider() { for (int i = 1; i < 6; i++) { SignInfo sign = new SignInfo(); sign.Name = "Sign" + i; _entitySet.RootGroup.AddSign(sign); } for (int i = 1; i < 6; i++) { SignGroupInfo group = new SignGroupInfo(); group.Name = "Group" + i; for (int j = 1; j <= i; j++) { SignInfo sign = new SignInfo(); sign.Name = "Sign" + j; group.AddSign(sign); sign.Parent = group; SignGroupInfo subGroup = new SignGroupInfo(); subGroup.Name = "SubGroup" + j; group.AddGroup(subGroup); subGroup.Parent = group; } _entitySet.RootGroup.AddGroup(group); } }
public void PopulateRelationTest1() { SignInfo sign = new SignInfo(); SignGroupInfo group = new SignGroupInfo(); group.Name = "group"; sign.Name = "sign"; group.Parent = tree; sign.Parent = group; //_tree.AddSign(sign); Serialiser <SignGroupTree> ser = Serialiser <SignGroupTree> .Binaray; using (MemoryStream stream = new MemoryStream()) { ser.Serialize(tree, stream); tree.Clear(); stream.Position = 0; tree = ser.Deserialise(stream); stream.Close(); } tree.PopulateRelation(); // Assert.AreEqual(1, tree.Groups.Length); Assert.AreEqual(1, tree.Groups[0].Signs.Length); Assert.AreEqual(0, tree.Signs.Length); }
/// <summary> /// Test PopulateRelation Function /// 测试条件:树有一个子组并且子组中有一个sign /// 测试方法:通过XML序列化,然后反序列化,调用PopulateRelation(),查看树的关系是否存在 /// </summary> //[Test] public void PopulateRelationTest6() { SignInfo sign = new SignInfo(); SignGroupInfo group = new SignGroupInfo(); group.Name = "group"; sign.Name = "sign"; group.Parent = tree; sign.Parent = group; SignGroupTree aa = new SignGroupTree(); Serialiser <SignGroupTree> ser = Serialiser <SignGroupTree> .Xml; using (MemoryStream stream = new MemoryStream()) { ser.Serialize(tree, stream); tree.Clear(); stream.Position = 0; aa = ser.Deserialise(stream); stream.Close(); } tree.PopulateRelation(); Assert.AreEqual(1, aa.Groups.Length); Assert.AreEqual(1, aa.Groups[0].Signs.Length); Assert.AreEqual(0, aa.Signs.Length); }
public void HasChangedTest() { SignGroupInfo group = new SignGroupInfo(); group.Name = "group"; //_tree.AddSign(sign); group.Parent = tree; Assert.AreEqual(true, tree.IsChanged); }
public void GetGroupByNameTest() { SignGroupInfo newsign = new SignGroupInfo(); newsign.Name = "test"; newsign.Parent = tree; Assert.IsTrue(Equals(newsign, SignGroupInfo.GetGroupByName("test"))); Assert.IsFalse(Equals(newsign, SignGroupInfo.GetGroupByName("test1"))); }
public void AcceptChangesTest() { SignGroupInfo group = new SignGroupInfo(); group.Name = "group"; // group.Parent = _tree; tree.AddGroup(group); Assert.AreEqual(true, tree.IsChanged); tree.AcceptChanges(); Assert.AreEqual(false, tree.IsChanged); }
public void HasChangedTest3() { Assert.AreEqual(false, tree.IsChanged); SignInfo sign = new SignInfo(); SignGroupInfo group = new SignGroupInfo(); group.Name = "group"; sign.Name = "sign"; group.Parent = tree; sign.Parent = group; Assert.AreEqual(true, tree.IsChanged); }
public void ParentNameTest() { SignGroupInfo newsign = new SignGroupInfo(); newsign.Name = "test"; newsign.Parent = tree; SignGroupInfo group = new SignGroupInfo(); group.Name = "group"; group.Parent = newsign; //SignGroupInfo.GetGroupByName("SignGroupTree"); Assert.IsTrue(Equals("[No Group]", newsign.ParentName)); // Assert.IsFalse(Equals(newsign, SignGroupInfo.GetGroupByName("test1"))); }
private void Add() { if (lbcDashboard.SelectedItems == null) { return; } DashboardItem dashboard; DashboardItem session = null; bool isContain = false; for (int i = 0; i < lbcDashboard.SelectedItems.Count; i++) { isContain = false; if (lbcSession.ItemCount > 0) { session = lbcSession.Items[0] as DashboardItem; } dashboard = lbcDashboard.SelectedItems[i] as DashboardItem; for (int j = 0; j < lbcSession.Items.Count; j++) { session = lbcSession.Items[j] as DashboardItem; if (dashboard.Name == session.Name) { isContain = true; } if (!isContain && dashboard.DashboardType == ProWrite.Core.DashboardType.Group) { if (session.DashboardType == ProWrite.Core.DashboardType.Group) { foreach (SignGroupInfo item in SignGroupInfo.FindAllGroups(dashboard as SignGroupInfo)) { if (item.Name == session.Name) { MsgBox.Error("The group '" + item.Name + "' has contained the group '" + session.Name + "'"); isContain = true; } } if (!isContain) { foreach (SignGroupInfo item in SignGroupInfo.FindAllGroups(session as SignGroupInfo)) { if (item.Name == dashboard.Name) { MsgBox.Error("The group '" + session.Name + "' has contained the group '" + item.Name + "'"); isContain = true; } } } } else { foreach (SignInfo item in SignGroupInfo.FindAllSigns(dashboard as SignGroupInfo)) { if (item.Name == session.Name) { MsgBox.Error("The group '" + item.Name + "' has contained the sign '" + session.Name + "'"); isContain = true; } } } } else if (!isContain) { if (session.DashboardType == ProWrite.Core.DashboardType.Group) { foreach (SignInfo item in SignGroupInfo.FindAllSigns(session as SignGroupInfo)) { if (item.Name == dashboard.Name) { MsgBox.Error("The group '" + session.Name + "' has contained the sign '" + item.Name + "'"); isContain = true; } } } } } if (!isContain) { lbcSession.Items.Add(lbcDashboard.SelectedItems[i]); lbcSession.SelectedIndex = lbcSession.ItemCount - 1; lbcDashboard.Items.Remove(lbcDashboard.SelectedItems[i]); } } }
protected override bool OnEdit() { if (!CheckSignInfo()) { return(false); } if (this.ddlSignParent.Text != SelectText && ddlSignParent.Text != Current.ParentName) { /////判断被拖入的Group的sign个数是否超过20 if (!SignGroupInfo.IsTwoGroupSameRoot(Current.Parent as SignGroupInfo, ddlSignParent.SelectedItem as SignGroupInfo)) { var parent = ddlSignParent.SelectedItem as SignGroupInfo; if (SignGroupInfo.IsSignCountValid(parent)) { MsgBox.Warning(Resource.GetString(Resource.Strings.SignsCountMoreThanTwenty)); return(false); } } } //如果SignParent选择的是“No Group”,则该Sign的Parent为树根 if (Current.Name != txtSignName.Text.Trim()) { if (DashboardItem._allSigns.Contains(txtSignName.Text.Trim()) || DashboardItem._allGroups.Contains(txtSignName.Text.Trim())) { MsgBox.Error(Resource.GetString(Resource.Strings.DashBoard_SaveSignRepeat)); return(false); } } #region About Connection /*/////////////////////////////////// * * */ if (isLiveSign && !_isAddToGroup) { //this.Enabled = false; this.btnSave.Enabled = false; if (isConnect) { //if (isOnline) // OnLogoff(); //else // OnDisConncetion(); DoDisconnect(); this.btnSave.Enabled = true; } else { if (!CheckLiveInfo()) { this.btnSave.Enabled = true; return(false); } Current.Name = txtSignName.Text.Trim(); DoConnect(); this.btnSave.Enabled = true; } //return false; } /*////////////////////////// * * * * //////////////////////////*/ #endregion if (!_isAddToGroup) { if (Current.Controller.Connection.State == System.Communication.ConnectionState.Opened) { int h = Current.Height; int w = Current.Width; Current.Height = 10000; Current.Width = 10000; LocalMessageBus.Send(this, new DataChangedMessage(PWDataType.Dashboard)); LocalMessageBus.Send(this, new ActiveChange(Current, false)); Current.Height = h; Current.Width = w; return(true); } Current.Name = txtSignName.Text.Trim(); //SetTemplate(); //SignType Current.Type = (SignType)Enum.Parse(typeof(SignType), ddlSignType.SelectedItem.ToString()); Current.IsWebCam = rdbWebCam.Checked; Current.Height = 10000; Current.Width = 10000; LocalMessageBus.Send(this, new DataChangedMessage(PWDataType.Dashboard)); LocalMessageBus.Send(this, new ActiveChange(Current, false)); Current.Height = Current.Template.Sign.Height = Convert.ToInt32(txtHeight.Text); Current.Width = Current.Template.Sign.Width = Convert.ToInt32(txtWidth.Text); //SetSignTemplateValue(); Current.Active = true; if (Current.DashboardType != DashboardType.Sign) { Current.SignInfomation = Current.Height.ToString() + " x " + Current.Width.ToString(); } //Current.SignInfomation = Current.Name + " : " + Current.Height.ToString() + " x " + Current.Width.ToString() + " : " + Current.Type.ToString(); Current.Template.Sign.SignType = Current.Type; if (btSignImage.Text.Trim() == "") { Current.Image = Current.Template.Sign.Image = ""; } } if (this.ddlSignParent.Text == SelectText) { Current.Parent = DataGate.Project.RootGroup; } else { var parent = ddlSignParent.SelectedItem as SignGroupInfo; if (!parent.IsSameSignType(Current, parent)) { MsgBox.Warning("Sign information is not equal"); return(false); } Current.Parent = ddlSignParent.SelectedItem as SignGroupInfo; } isSaveClose = true; return(true); }
/// <summary> /// Save data /// </summary> protected override void OnSave() { if (!CheckSignInfo()) { return; } //判断是否选中了No Group Current.Name = txtSignName.Text.Trim(); //SetTemplate(); Current.Type = (SignType)Enum.Parse(typeof(SignType), ddlSignType.SelectedItem.ToString()); Current.Height = Current.Template.Sign.Height = Convert.ToInt32(txtHeight.Text); Current.Width = Current.Template.Sign.Width = Convert.ToInt32(txtWidth.Text); //SetSignTemplateValue(); Current.Active = true; Current.IsWebCam = rdbWebCam.Checked; if (Current.DashboardType != DashboardType.Sign) { Current.SignInfomation = Current.Height.ToString() + " x " + Current.Width.ToString(); } //Current.SignInfomation = Current.Name + " : " + Current.Height.ToString() + " x " + Current.Width.ToString() + " : " + Current.Type.ToString(); Current.Template.Sign.SignType = Current.Type; if (isLiveSign) { Current.DashboardType = DashboardType.Sign; } else { Current.DashboardType = DashboardType.DemoSign; } if (this.ddlSignParent.Text != SelectText) { //Current.Parent = ddlSignParent.SelectedItem as SignGroupInfo; _Parent = ddlSignParent.SelectedItem as SignGroupInfo; /////判断被拖入的Group的sign个数是否超过20 if (SignGroupInfo.IsSignCountValid(_Parent)) { MsgBox.Warning(Resource.GetString(Resource.Strings.SignsCountMoreThanTwenty)); return; } if (!_Parent.IsSameSignType(Current, _Parent)) { MsgBox.Warning("Sign information is not equal"); return; } } //如果是,则将_Parent置为根 else { _Parent = DataGate.Project.RootGroup; } #region Connection /*/////////////////////////////////// * * */ if (isLiveSign && Current.Controller.Connection.State != System.Communication.ConnectionState.Opened) { if (!CheckLiveInfo()) { return; } btnSave.Enabled = false; DoConnect(); btnSave.Enabled = true; //ControlService.SignCombo.Current = Current; //LocalMessageBus.Send(this, new PWMessage<MenuCommands>(MenuCommands.NewMessage)); //LocalMessageBus.Send(this, new PWMessage<MenuCommands>(MenuCommands.NewPlaylist)); //LocalMessageBus.Send(this, new PWMessage<MenuCommands>(MenuCommands.NewScheduler)); return; } /*////////////////////////// * * * * //////////////////////////*/ #endregion //判断是否添加新项成功 if (!_Parent.AddSign(Current)) { MsgBox.Error(Resource.GetString(Resource.Strings.DashBoard_SaveSignRepeat)); return; } //判断是否需要上传图片 if (btSignImage.Text.Length > 0) { //DataGate.Upload(btSignImage.Text); UpLoad(); Current.Image = Current.Template.Sign.Image = strImageFullName; } DataGate.Update(); this.IsRefresh = true; isSaveClose = true; this.Close(); //LocalMessageBus.Send(this, MenuCommands.NewPlaylist); //LocalMessageBus.Send(this, MenuCommands.NewScheduler); }
/// <summary> /// Add sign /// </summary> /// <param name="parent"></param> public SignForm(SignGroupInfo parent) : base(parent) { InitializeComponent(); RegisterHelp(); }