private void butTest_Click(object sender, RoutedEventArgs e) { ISectionHeader sh = this.Model; // find the first ScreenSection. set to the items of that section. var sect = sh.Items.OfType <ScreenSectionModel>().First(); if (sect != null) { sh = sect; } var found = sh.Items.FirstOrDefault(c => c.ItemName == "abc3"); if (found != null) { sh.RemoveItem(found); } var item = new ScreenLiteralModel(); item.ItemName = "abc3"; item.ScreenLoc = new OneScreenLoc(1, 5); sh.AddItem(item); }
private void butAdd_Click(object sender, RoutedEventArgs e) { var item = new ScreenLiteral(); var model = new ScreenLiteralModel(item); WorkScreenItemWindow.WorkScreenItem(ActionCode.Add, this.Model, model); }
private void MenuItem_Click(object sender, RoutedEventArgs e) { MenuItem mi = null; if (sender is MenuItem) { mi = sender as MenuItem; } if (mi != null) { var itemText = mi.Header as string; if (itemText == "Delete") { var model = lbScreenItems.SelectedItem as ScreenItemModel; if (model != null) { var ix = this.SectionHeader.ItemIndexOf(model); this.SectionHeader.RemoveItem(model); this.SectionHeader.OnSectionHeaderChanged(); } } else if (itemText == "Change") { ListBox_ChangeSelectedItem(lbScreenItems); this.SectionHeader.OnSectionHeaderChanged(); } else if (itemText == "Insert") { // create the new screen item. var model = new ScreenLiteralModel(); // insert after the selected item. var insertBase = lbScreenItems.SelectedItem as ScreenItemModel; if (insertBase != null) { // insert after the selected item var ix = this.SectionHeader.ItemIndexOf(insertBase); this.SectionHeader.InsertItemAfter(ix, model); this.SectionHeader.OnSectionHeaderChanged(); } // no selected item. ( list could be empty ). Add to end of list. else { this.SectionHeader.AddItem(model); } // run the work with window to edit the just inserted item. lbScreenItems.SelectedItem = model; ListBox_ChangeSelectedItem(lbScreenItems); } else if (itemText == "Move up") { var moveModel = lbScreenItems.SelectedItem as IScreenItem; if (moveModel != null) { var ix = lbScreenItems.SelectedIndex; ScreenDefnGlobal.CopyPasteList.AddCut(moveModel); ScreenDefnGlobal.CopyPasteList.PasteAfter(this.SectionHeader, ix - 2); this.SectionHeader.OnSectionHeaderChanged(); lbScreenItems.FindFocusItem(moveModel); } } else if (itemText == "Move down") { var moveModel = lbScreenItems.SelectedItem as IScreenItem; if (moveModel != null) { MoveDown(moveModel); lbScreenItems.FindFocusItem(moveModel); } } else if (itemText == "Cut") { CutSelected(); } else if (itemText == "Copy") { CopySelected(); } else if (itemText == "Paste") { DoPaste(); } } }
/// <summary> /// import the ContentItems of the current ScreenContent. Use the MasterThread /// property to send a message to the MasterThread asking for a copy of the /// current screenContent. That sent message waits for a response and receives /// the screenContent as the reply. With the screenContent, then list the /// ScreenContent items and import into ScreenDefn. /// /// Necessary for this to work, the telnetClient which is the parent of the /// ScreenDefnListControl must bind to the MasterThread property. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void butImport_Click(object sender, RoutedEventArgs e) { // send a message to the master thread asking for a copy of the current // screenContent. ScreenContent content = null; { var msg = new ExchangeMessage(ThreadMessageCode.GetScreenContent); this.MasterThread.PostInputMessage(msg); msg.WaitReplyEvent(); content = msg.ReplyMessage as ScreenContent; } // create screen section. type body. var section = new ScreenSectionModel() { ScreenLoc = new OneScreenLoc(1, 1), ItemName = "Body", ItemType = ShowItemType.Section, PurposeCode = ScreenPurposeCode.Body }; this.Model.AddItem(section); int fieldNum = 0; int litNum = 0; foreach (var citem in content.ContentItems( )) { if (citem is ContentField) { var fld = citem as ContentField; { fieldNum += 1; var xx = fld.IsBypass; var item = new ScreenFieldModel() { ScreenLoc = new OneScreenLoc(fld.RowCol.ToOneBased()), ItemName = "Field" + fieldNum, Length = fld.LL_Length, ItemType = ShowItemType.Field, Usage = fld.Usage, DsplyAttr = fld.AttrByte.ToDsplyAttr() }; section.AddItem(item); } } else if (citem is ContentText) { var contentText = citem as ContentText; { litNum += 1; var item = new ScreenLiteralModel() { ScreenLoc = new OneScreenLoc(contentText.RowCol.ToOneBased()), ItemName = "Lit" + litNum, ListValues = contentText.GetShowText(content).ToListString().ToObservableCollection( ), Length = contentText.GetShowText(content).Length, ItemType = ShowItemType.Literal, DsplyAttr = contentText.GetAttrByte(content).ToDsplyAttr() }; #if skip // adjust screenLoc to account for neutral dsply attr. if (item.DsplyAttr.IsEqual(DsplyAttr.NU)) { item.ScreenLoc = item.ScreenLoc.Advance(1, new AutoCoder.Telnet.Common.ScreenDm.ScreenDim(24, 80)) as OneScreenLoc; } #endif section.AddItem(item); } } } }