/// <summary> /// 建立新 tblProjectGroup 物件。 /// </summary> /// <param name="projectID">ProjectID 屬性的初始值。</param> /// <param name="groupID">GroupID 屬性的初始值。</param> public static tblProjectGroup CreatetblProjectGroup(global::System.Int32 projectID, global::System.Int32 groupID) { tblProjectGroup tblProjectGroup = new tblProjectGroup(); tblProjectGroup.ProjectID = projectID; tblProjectGroup.GroupID = groupID; return tblProjectGroup; }
private void treeView1_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e) { TreeView tv = (sender as TreeView); if (tv.SelectedItem == null) return; if (tv.SelectedItem is tblProjectGroup) { if (currentGroup != tv.SelectedItem as tblProjectGroup) { currentGroup = tv.SelectedItem as tblProjectGroup; DrawDevices(); } } else if (tv.SelectedItem is tblDevice) { if (currentGroup != (tv.SelectedItem as tblDevice).tblProjectGroupSection.tblProjectGroup) { currentGroup = (tv.SelectedItem as tblDevice).tblProjectGroupSection.tblProjectGroup; DrawDevices(); } UnSelectAllDevice(); (tv.SelectedItem as tblDevice).UIDevice.IsSelected = true; scrollViewer1.ScrollIntoView((tv.SelectedItem as tblDevice).UIDevice as FrameworkElement); } else //section seclect { if (currentGroup != (tv.SelectedItem as tblProjectGroupSection).tblProjectGroup) { currentGroup = (tv.SelectedItem as tblProjectGroupSection).tblProjectGroup; DrawDevices(); } UnSelectAllDevice(); foreach (tblDevice dev in (tv.SelectedItem as tblProjectGroupSection).tblDevice) { if (dev.UIDevice != null) dev.UIDevice.IsSelected = true; } } }
/// <summary> /// 將新物件加入 tblProjectGroup EntitySet 的方法已被取代。請考慮改為使用關聯的 ObjectSet<T> 屬性的 .Add 方法。 /// </summary> public void AddTotblProjectGroup(tblProjectGroup tblProjectGroup) { base.AddObject("tblProjectGroup", tblProjectGroup); }
//private void AddSection_Click(object sender, RoutedEventArgs e) //{ // //chldInputBox inputbox = new chldInputBox("LedProjectMaker", "請輸入控群名稱"); // //tblProjectGroup group = treeView1.SelectedItem as tblProjectGroup; // //inputbox.Closed+=(s,a)=> // // { // // if(inputbox.DialogResult==true) // // currentGroup.tblProjectGroupSection.Add( // // new tblProjectGroupSection() { ProjectID = group.ProjectID, // // GroupID = group.GroupID, // // SectionName = inputbox.InputString}); // // }; // //inputbox.Show(); //} //private void SectionDel_Click(object sender, RoutedEventArgs e) //{ // tblProjectGroupSection section = treeView1.SelectedItem as tblProjectGroupSection; // if (section == null) // return; // dbservice.tblProjectGroupSections.Remove(section); //} private void Section_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { treeView1.SelectItem((sender as StackPanel).DataContext); currentGroup = ((sender as StackPanel).DataContext as tblProjectGroupSection).tblProjectGroup; }