public override void Read(Stream stream, int count, FrameContent content) { CodecState state = new CodecState(); CodecItem codecItem = CodecItemByFrameId(FrameId); (content as FrameContentText).Text = codecItem.Read(state, stream) as string; }
private static FrameContent ConvertContent(FrameContent content, string dstFrameId, Version dst) { TagDescription dstMap = TagDescriptionMap.Instance[dst]; Type dstType = dstMap.ContentClass(dstMap[dstFrameId].Type); return(FrameContentConverter.Convert(content, dstType)); }
public virtual int RequiredBytes( FrameContent frameContent, bool desynchronization, Reader.UnsyncMode unsyncMode) { if (unsyncMode == Reader.UnsyncMode.CountIncludesUnsyncBytes) { using (Writer writer = new Writer()) { writer.Unsynchronization = desynchronization; using (WriterStream stream = new WriterStream(writer)) { frameContent.Codec.Write(stream, frameContent); } writer.Flush(); return((int)writer.Length); } } else if (unsyncMode == Reader.UnsyncMode.CountExcludesUnsyncBytes) { using (MemoryStream stream = new MemoryStream()) { frameContent.Codec.Write(stream, frameContent); return((int)stream.Length); } } else { throw new NotSupportedException("Unknown unsync mode"); } }
public MenuPoint(string resourceName, FrameContent content, Assembly assembly, Color backgroundColor, int logoTopMargin, int menuHeight, int position, int menuWidth) { this.resourceName = resourceName; this.frameContent = content; MenuRectangle = new Rectangle(0, logoTopMargin + menuHeight * position, menuWidth, menuHeight); menuActiveLine = new SolidBrush(Color.FromArgb(255, 31, 214, 208)); menuNonactiveLine = new SolidBrush(backgroundColor); menuActiveRectangle = new Rectangle(0, logoTopMargin + menuHeight * position, 5, menuHeight); pointLightPicture = new PictureBox { Name = "light" + resourceName, Size = new Size(32, 32), Location = new Point((menuWidth - activePicWidth) / 2, (logoTopMargin + menuHeight * position) + (menuHeight - activePicHeight) / 2), Image = Image.FromStream(assembly.GetManifestResourceStream("MinerGUI.Resources.Menu.Light." + resourceName)), BackColor = backgroundColor, SizeMode = PictureBoxSizeMode.StretchImage }; pointDarkPicture = new PictureBox { Name = "dark" + resourceName, Size = new Size(32, 32), Location = new Point((menuWidth - activePicWidth) / 2, (logoTopMargin + menuHeight * position) + (menuHeight - activePicHeight) / 2), Image = Image.FromStream(assembly.GetManifestResourceStream("MinerGUI.Resources.Menu.Dark." + resourceName)), BackColor = backgroundColor, SizeMode = PictureBoxSizeMode.StretchImage }; }
private void Nv_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args) { if (args.SelectedItem != null && args.SelectedItem is ViewItem vi) { FrameContent.Navigate(views[vi.Id], vi.ParamGetter?.Invoke()); } }
public override void Write(Stream stream, FrameContent content) { CodecState state = new CodecState(); CodecItem codecItem = CodecItemByFrameId(FrameId); codecItem.Write(state, stream, (content as FrameContentText).Text); }
private void NavView_BackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args) { if (FrameContent.CanGoBack) { FrameContent.GoBack(); } }
/// <summary> /// Send a frame to this node. /// </summary> /// <param name="frame"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task ExecuteAsync(FrameContent frame, CancellationToken cancellationToken) { if (!IsOpen) { throw new InvalidOperationException("Controller must be open to execute commands."); } await _connection.Send(frame, cancellationToken); }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (e.Parameter != null) { LaunchData ld = JsonConvert.DeserializeObject <LaunchData>((string)e.Parameter); if (ld != null && ld.type == typeof(Task)) { FrameContent.Navigate(typeof(AddTask), ld.data); } } }
private void UpdateFrame() { if (ViewModel.IsGridView) { FrameContent.Navigate(typeof(GridViewFrame)); } else if (ViewModel.IsListView) { FrameContent.Navigate(typeof(ListViewFrame)); } }
public override void Read(Stream stream, int count, FrameContent content) { state.ItemCount = codecItems.Count; for (state.ItemIndex = 0; state.ItemIndex < state.ItemCount; state.ItemIndex++) { CodecItem entry = codecItems[state.ItemIndex]; object value = entry.Read(state, stream); object target = ObjectByTarget(entry.DestinationObject, content); SetProperty(PropInfo(target, entry.PropertyName), target, value); } }
private void OnFrameReceived(object sender, FrameReceivedEventArgs e) { FrameContent content = e.FrameContent; if (content is ModemStatusFrame) { var modemStatusFrame = content as ModemStatusFrame; _modemResetTaskCompletionSource?.SetResult(modemStatusFrame.ModemStatus); } else if (content is CommandResponseFrameContent) { var commandResponse = content as CommandResponseFrameContent; byte frameId = commandResponse.FrameId; TaskCompletionSource <CommandResponseFrameContent> taskCompletionSource; if (ExecuteTaskCompletionSources.TryRemove(frameId, out taskCompletionSource)) { taskCompletionSource.SetResult(commandResponse); } else { Action <CommandResponseFrameContent> callback; if (ExecuteCallbacks.TryGetValue(frameId, out callback)) { callback(commandResponse); } } } else if (content is IRxIndicatorDataFrame) { var dataFrame = content as IRxIndicatorDataFrame; NodeAddress address = dataFrame.GetAddress(); _receivedDataSource.Push(new SourcedData(address, dataFrame.Data)); DataReceived?.Invoke(this, new SourcedDataReceivedEventArgs(address, dataFrame.Data)); } else if (content is IRxIndicatorSampleFrame) { var sampleFrame = content as IRxIndicatorSampleFrame; NodeAddress address = sampleFrame.GetAddress(); Sample sample = sampleFrame.GetSample(); _sampleSource.Push(new SourcedSample(address, sample)); SampleReceived?.Invoke(this, new SourcedSampleReceivedEventArgs(address, sample.DigitalSampleState, sample.AnalogSamples)); } }
public void SetFrameContent(FrameContent frameContent, Point viewportSize) { this.Result = FrameResult.Cancel; this.frameContent = frameContent; this.frameContent.Function = this.Function; this.TitleText.Text = frameContent.GetCurrentTitle(); frameContent.FramePosition = StaticMethods.GetRectangleFitViewport(frameContent.DefaultFrameWidth, frameContent.DefaultFrameHeight, viewportSize); this.OKButtonPosition = frameContent.OKButtonPosition; this.CancelButtonPosition = frameContent.CancelButtonPosition; this.MapViewSelectorButtonPosition = frameContent.MapViewSelectorButtonPosition; this.SetPosition(frameContent.FramePosition); frameContent.ReCalculate(); frameContent.InitializeMapViewSelectorButton(); frameContent.OnItemClick += new FrameContent.ItemClick(this.frameContent_OnItemClick); }
private void Check(FrameContent frameContent, byte[] expectedValue) { var frame = new Frame(frameContent); var actualValue = _frameSerializer.Serialize(frame); Assert.AreEqual(expectedValue.Length, actualValue.Length, "Actual data length does not match expected length."); for (int i = 0; i < expectedValue.Length; i++) { var expected = expectedValue[i]; var actual = actualValue[i]; Assert.AreEqual(expected, actual, $"Value at position {i} does not match expected value."); } }
private void OnItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewItemInvokedEventArgs args) { switch (args.InvokedItemContainer.Tag) { case "Page #1": FrameContent.Navigate(typeof(Page1)); break; case "Page #2": FrameContent.Navigate(typeof(Page2)); break; default: Frame.Navigate(typeof(Page3)); break; } }
public async Task Send(FrameContent frameContent, CancellationToken cancellationToken) { byte[] data = _frameSerializer.Serialize(new Frame(frameContent)); await _writeSemaphoreSlim.WaitAsync(cancellationToken); try { #if NETCORE await _serialPort.OutputStream.WriteAsync(data.AsBuffer()); #else await _serialPort.BaseStream.WriteAsync(data, 0, data.Length, cancellationToken); #endif } finally { _writeSemaphoreSlim.Release(); } }
private static void TestCodec(byte[] data, FrameContent content, bool checkBinaryEqual = true) { using (MemoryStream memStr = new MemoryStream(data, 0, data.Length)) { content.Codec.Read(memStr, data.Length, content); using (Writer writer = new Writer()) { using (WriterStream oStream = new WriterStream(writer)) { content.Codec.Write(oStream, content); } if (checkBinaryEqual) { UnitTest.Test(ArrayUtils.IsEqual(data, writer.OutData)); } } } }
private async void MainViewModel_PropertyChangedAsync(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var vm = sender as MainViewModel; switch (e.PropertyName) { case nameof(vm.CurrentViewModelName): FrameContent.Navigate(viewNames[vm.CurrentViewModelName]); break; case nameof(vm.AlertMessage): await new ContentDialog { Content = vm.AlertMessage, PrimaryButtonText = "OK" }.ShowAsync(); break; default: Debug.WriteLine($"MainViewModel_PropertyChanged {e.PropertyName}"); break; } }
public MainWindow() { InitializeComponent(); ViewModel = new MainWindowViewModel(); DataContext = ViewModel; App.MainFrame = FrameContent; switch (ViewModel.CheckDatabaseConfiguration()) { case -1: FrameContent.Navigate(new InitialConfigPage()); break; case 0: App.DbContext = new ShcDbContext(App.SERVER_IP); ViewModel.InitializeDatabase(); FrameContent.Navigate(new HomePage()); break; } }
public async void InitializeAfterDataLoad() { while (!Data.loadingFinished) { await System.Threading.Tasks.Task.Delay(10); } bool registered = false; foreach (var task in BackgroundTaskRegistration.AllTasks) { if (task.Value.Name == "BackgroundTileNotificationUpdate") { registered = true; break; } } if (!registered) { LiveTileBackgroundUpdater.PrepareLiveTile(); } FrameContent.Navigate(typeof(WeekView)); }
private void MenuGrid_Tapped(object sender, TappedRoutedEventArgs e) { if (NavigationPane.IsPaneOpen) { NavigationPane.IsPaneOpen = !NavigationPane.IsPaneOpen; } MenuItem menu = LeftMenu.SelectedItem as MenuItem; if (menu != null) { if (menu.NavigateTo != null) { CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { FrameContent.Navigate(menu.NavigateTo); }); } } }
public Frame(FrameContent content) : this() { Payload = new FramePayload(content); }
private void MainPage_Loaded(object sender, RoutedEventArgs e) { var vm = App.Current.BizLogic.MainViewModel; FrameContent.Navigate(viewNames[vm.CurrentViewModelName]); }
private void NavLinksList_ItemClick(object sender, ItemClickEventArgs e) { NavLink link = (NavLink)e.ClickedItem; FrameContent.Navigate(link.Page); }
public MainPage() { this.InitializeComponent(); FrameContent.Navigate(typeof(Page1)); }
public FramePayload(FrameContent content) { Content = content; }
// Menu Page de crédits private void MenuItem_Click_1(object sender, RoutedEventArgs e) { FrameContent.Navigate(new System.Uri("About.xaml", UriKind.RelativeOrAbsolute)); }
// Menu liste des RDV private void ListRdv_Click(object sender, RoutedEventArgs e) { FrameContent.Navigate(new System.Uri("appointmentsList.xaml", UriKind.RelativeOrAbsolute)); }
public Main() { //Windows.Globalization.ApplicationLanguages.PrimaryLanguageOverride = "cs"; this.InitializeComponent(); instance = this; var titleBar = Windows.UI.ViewManagement.ApplicationView.GetForCurrentView().TitleBar; // Title bar colors. Alpha must be 255. titleBar.BackgroundColor = new Color() { A = 255, R = 60, G = 120, B = 240 }; titleBar.ForegroundColor = new Color() { A = 255, R = 220, G = 220, B = 255 }; titleBar.InactiveBackgroundColor = new Color() { A = 255, R = 60, G = 120, B = 240 }; titleBar.InactiveForegroundColor = new Color() { A = 255, R = 220, G = 220, B = 255 }; // Title bar button background colors. Alpha is respected when the view is extended // into the title bar (see scenario 2). Otherwise, Alpha is ignored and treated as if it were 255. titleBar.ButtonBackgroundColor = new Color() { A = 255, R = 60, G = 120, B = 240 }; titleBar.ButtonHoverBackgroundColor = new Color() { A = 255, R = 50, G = 100, B = 200 }; titleBar.ButtonPressedBackgroundColor = new Color() { A = 255, R = 232, G = 211, B = 162 }; titleBar.ButtonInactiveBackgroundColor = new Color() { A = 255, R = 60, G = 120, B = 240 }; // Title bar button foreground colors. Alpha must be 255. titleBar.ButtonForegroundColor = new Color() { A = 255, R = 220, G = 220, B = 255 }; titleBar.ButtonHoverForegroundColor = new Color() { A = 255, R = 220, G = 220, B = 255 }; titleBar.ButtonPressedForegroundColor = new Color() { A = 255, R = 220, G = 220, B = 255 }; titleBar.ButtonInactiveForegroundColor = new Color() { A = 255, R = 220, G = 220, B = 255 }; SystemNavigationManager.GetForCurrentView().BackRequested += (sender, args) => { if (canGoBack) { FrameContent.GoBack(); } }; ResourceLoader resourceLoader = new ResourceLoader(); foreach (var link in _navLinks) { link.Label = resourceLoader.GetString(link.Label); } foreach (var link in _displayStyles) { link.Label = resourceLoader.GetString(link.Label); } InitializeAfterDataLoad(); }
// Menu ajout courtier private void AddBroker_Click(object sender, RoutedEventArgs e) { FrameContent.Navigate(new System.Uri("addBroker.xaml", UriKind.RelativeOrAbsolute)); }