Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();
            ProtocolController = new ProtocolController();
            //GenTestData();

            Loaded += OnLoaded;

            CbProtocols.SelectionChanged += CbProtocolsOnSelectionChanged;
            LbPackets.SelectionChanged += LbPacketsOnSelectionChanged;
            LbSegments.SelectionChanged += LbSegmentsOnSelectionChanged;
            LbPackets.MouseDoubleClick += LbPacketsOnMouseDoubleClick;
            LbPackets.KeyUp += LbPacketsOnKeyUp;

            //  Говно-код, но иначе не получается получить доступ
            //  к ComboBox внутри ContentControl.ContentTemplate
            //  для инициализации SelectedItem
            CbDataType.ItemsSource = Segment.GetDataTypes();
            TxtSegmentName.TextChanged += TxtSegmentNameOnTextChanged;
            TxtSegmentName.LostFocus += TxtSegmentNameOnLostFocus;
            TxtSegmentDesc.TextChanged += TxtSegmentDescOnTextChanged;
            TxtSegmentDesc.LostFocus += TxtSegmentDescOnLostFocus;
            CbDataType.SelectionChanged += CbDataTypeOnSelectionChanged;
            CbDataType.DropDownClosed += CbDataTypeOnDropDownClosed;
            TxtSegmentSize.TextChanged += TxtSizeOnTextChanged;
            TxtSegmentSize.LostFocus += TxtSegmentSizeOnLostFocus;
            CbPacketType.SelectionChanged += CbPacketTypeOnSelectionChanged;
            CbDynamicSize.DropDownClosed += CbDynamicSizeOnDropDownClosed;
            InitTimer();
            //  Конец говно-кода
        }
Ejemplo n.º 2
0
 public static void SaveProtocols(ProtocolController storage)
 {
     if (string.IsNullOrEmpty(storage.FileName)) {
         var dlg = new SaveFileDialog {
             Title = "Save protocols to XML Storage",
             FileName = "Protocols",
             DefaultExt = ".xml",
             Filter = "Protocols XML Storage (.xml)|*.xml"
         };
         var result = (bool) dlg.ShowDialog();
         if (!result) return;
         storage.FileName = dlg.FileName;
     }
     var xml = new XmlSerializer(typeof(ProtocolController));
     using (var writer = new StreamWriter(storage.FileName)) {
         xml.Serialize(writer, storage);
     }
 }
Ejemplo n.º 3
0
        public static void SaveProtocols(ProtocolController storage)
        {
            if (string.IsNullOrEmpty(storage.FileName))
            {
                var dlg = new SaveFileDialog {
                    Title      = "Save protocols to XML Storage",
                    FileName   = "Protocols",
                    DefaultExt = ".xml",
                    Filter     = "Protocols XML Storage (.xml)|*.xml"
                };
                var result = (bool)dlg.ShowDialog();
                if (!result)
                {
                    return;
                }
                storage.FileName = dlg.FileName;
            }
            var xml = new XmlSerializer(typeof(ProtocolController));

            using (var writer = new StreamWriter(storage.FileName)) {
                xml.Serialize(writer, storage);
            }
        }