private void butConvertToOutputField_Click(object sender, RoutedEventArgs e) { this.Model = ScreenItemModel.Factory(ShowItemType.Field, this.Model); (this.Model as ScreenFieldModel).Usage = ShowUsage.Output; this.ModelTypeChanged = true; AcceptEntry(); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { this.Model = ScreenItemModel.Factory(this.ScreenItemModel); this.DataContext = this; // screenSection. Make the window larger. if (this.Model is IScreenSection) { this.Width += 150; this.Height += 250; } }
public static void ReplaceModel( this ISectionHeader sectionHeader, ScreenItemModel itemModel, ScreenItemModel screenItemModel) { var ix = sectionHeader.ItemIndexOf(itemModel); if (ix >= 0) { sectionHeader.InsertItemBefore(ix, screenItemModel); sectionHeader.RemoveItem(itemModel); } }
bool ListBox_ChangeItem(ScreenItemModel item) { bool handled = false; if (item != null) { var sectionHeader = item.SectionHeader; WorkScreenItemWindow.WorkScreenItem(ActionCode.Change, sectionHeader, item); handled = true; } return(handled); }
private void EnumRadioButton_EnumValueChanged( Enum wasValue, Enum currentValue, AutoCoder.Controls.EnumRadioButton arg2) { var itemType = (ShowItemType)currentValue; ShowItemType?wasType = (ShowItemType?)wasValue; // type of the ScreenItem has been changed. Create a new ItemModel that // matches the new item type. if ((wasType != null) && (wasType.Value != itemType)) { this.Model = ScreenItemModel.Factory(itemType, this.Model); this.ModelTypeChanged = true; AcceptEntry(); } }
public static void WorkScreenItem( ActionCode action, ISectionHeader sectionHeader, ScreenItemModel itemModel) { bool cancelAction = false; while (true) { var window = new WorkScreenItemWindow(action); window.ScreenItemModel = itemModel; var rv = window.ShowDialog(); if ((rv == null) || (rv.Value == false)) { cancelAction = true; break; } if (window.ModelTypeChanged == true) { if (action != ActionCode.Add) { sectionHeader.ReplaceModel(itemModel, window.ScreenItemModel); sectionHeader.OnSectionHeaderChanged(); } itemModel = window.ScreenItemModel; continue; } else { // the selectedItem was passed by reference. On return that same reference // has been updated by the WorkScreenItemWindow. No need to apply to the // itemsSource. It is already updated. cancelAction = false; itemModel = window.ScreenItemModel; break; } } // entry accepted. Add to list of items. if ((cancelAction == false) && (action == ActionCode.Add)) { sectionHeader.AddItem(itemModel); } }
private IScreenItem Paste_Actual( RelativePosition Rltv, ISectionHeader ToSectionHeader, int ToIndex = -1) { int toIndex = ToIndex; IScreenItem lastPasteItem = null; if (ToIndex >= 0) { lastPasteItem = ToSectionHeader.GetItemAt(ToIndex); } var rltv = Rltv; foreach (var item in this) { IScreenItem pasteItem = null; // remove from the from list. if (item.CopyPasteCode == CopyPasteCode.Cut) { pasteItem = item.Cut(); } // dup the item to copy. if (item.CopyPasteCode == CopyPasteCode.Copy) { pasteItem = ScreenItemModel.Factory(item.ScreenItem); pasteItem.AssignItemGuid(); } // index of the insert relative to item. toIndex = -1; if (lastPasteItem != null) { toIndex = ToSectionHeader.Items.IndexOf(lastPasteItem); } // insert into ToList. if (rltv == RelativePosition.After) { ToSectionHeader.InsertItemAfter(toIndex, pasteItem); } else if (rltv == RelativePosition.Begin) { ToSectionHeader.InsertItemBegin(pasteItem); } else if (rltv == RelativePosition.End) { ToSectionHeader.AddItem(pasteItem); } else if (rltv == RelativePosition.Before) { ToSectionHeader.InsertItemBefore(toIndex, pasteItem); } else { throw new Exception("invalid relative postion"); } // clear the copy/paste marking on the screenItem. if (this.IsGlobalList == true) { item.ScreenItem.CopyPasteCode = null; } // the last pasted item. lastPasteItem = pasteItem; // subsequent items are placed after the prior pasted item rltv = RelativePosition.After; } // clear the list of pending actions. this.Clear(); return(lastPasteItem); }