-
Notifications
You must be signed in to change notification settings - Fork 0
Updated the trackball sample #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Saravanan-Madhesh
merged 10 commits into
master
from
Prepare_sample_for_trackball_synchronize
Jan 2, 2025
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
727e8e9
Updated the trackball sample
37e7e07
deleted the user proj file
9ee89de
Removed the json and updated the label format
b009a13
removed .vs file
5d253ac
Update README.md
4570180
Update README.md
1638ece
Update README.md
a24a745
Update README.md
VimalaThirumalaikumar 19881a1
created the model and view model in seperate class
1cd0517
Merge branch 'Prepare_sample_for_trackball_synchronize' of https://gi…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
Synchronize_Trackball/.vs/Synchronize_Trackball/v17/DocumentLayout.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| { | ||
| "Version": 1, | ||
| "WorkspaceRootPath": "D:\\WPF Samples\\Synchronize_Trackball\\", | ||
| "Documents": [ | ||
| { | ||
| "AbsoluteMoniker": "D:0:0:{2AE8056D-FC80-4398-A603-35E59086C4CA}|Synchronize_Trackball.csproj|d:\\wpf samples\\synchronize_trackball\\mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}", | ||
| "RelativeMoniker": "D:0:0:{2AE8056D-FC80-4398-A603-35E59086C4CA}|Synchronize_Trackball.csproj|solutionrelative:mainwindow.xaml||{F11ACC28-31D1-4C80-A34B-F4E09D3D753C}" | ||
| }, | ||
| { | ||
| "AbsoluteMoniker": "D:0:0:{2AE8056D-FC80-4398-A603-35E59086C4CA}|Synchronize_Trackball.csproj|d:\\wpf samples\\synchronize_trackball\\mainwindow.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}", | ||
| "RelativeMoniker": "D:0:0:{2AE8056D-FC80-4398-A603-35E59086C4CA}|Synchronize_Trackball.csproj|solutionrelative:mainwindow.xaml.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}" | ||
| } | ||
| ], | ||
| "DocumentGroupContainers": [ | ||
| { | ||
| "Orientation": 0, | ||
| "VerticalTabListWidth": 256, | ||
| "DocumentGroups": [ | ||
| { | ||
| "DockedWidth": 200, | ||
| "SelectedChildIndex": 4, | ||
| "Children": [ | ||
| { | ||
| "$type": "Bookmark", | ||
| "Name": "ST:0:0:{b1e99781-ab81-11d0-b683-00aa00a3ee26}" | ||
| }, | ||
| { | ||
| "$type": "Bookmark", | ||
| "Name": "ST:0:0:{34e76e81-ee4a-11d0-ae2e-00a0c90fffc3}" | ||
| }, | ||
| { | ||
| "$type": "Bookmark", | ||
| "Name": "ST:0:0:{d78612c7-9962-4b83-95d9-268046dad23a}" | ||
| }, | ||
| { | ||
| "$type": "Document", | ||
| "DocumentIndex": 1, | ||
| "Title": "MainWindow.xaml.cs", | ||
| "DocumentMoniker": "D:\\WPF Samples\\Synchronize_Trackball\\MainWindow.xaml.cs", | ||
| "RelativeDocumentMoniker": "MainWindow.xaml.cs", | ||
| "ToolTip": "D:\\WPF Samples\\Synchronize_Trackball\\MainWindow.xaml.cs", | ||
| "RelativeToolTip": "MainWindow.xaml.cs", | ||
| "ViewState": "AgIAAEcAAAAAAAAAAAAuwGAAAAAFAAAAAAAAAA==", | ||
| "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|", | ||
| "WhenOpened": "2024-12-13T10:58:11.468Z", | ||
| "EditorCaption": "" | ||
| }, | ||
| { | ||
| "$type": "Document", | ||
| "DocumentIndex": 0, | ||
| "Title": "MainWindow.xaml", | ||
| "DocumentMoniker": "D:\\WPF Samples\\Synchronize_Trackball\\MainWindow.xaml", | ||
| "RelativeDocumentMoniker": "MainWindow.xaml", | ||
| "ToolTip": "D:\\WPF Samples\\Synchronize_Trackball\\MainWindow.xaml", | ||
| "RelativeToolTip": "MainWindow.xaml", | ||
| "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003549|", | ||
| "WhenOpened": "2024-12-13T10:58:05.535Z", | ||
| "EditorCaption": "" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <Application x:Class="Synchronize_Trackball.App" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:local="clr-namespace:Synchronize_Trackball" | ||
| StartupUri="MainWindow.xaml"> | ||
| <Application.Resources> | ||
|
|
||
| </Application.Resources> | ||
| </Application> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| using System.Configuration; | ||
| using System.Data; | ||
| using System.Windows; | ||
|
|
||
| namespace Synchronize_Trackball | ||
| { | ||
| /// <summary> | ||
| /// Interaction logic for App.xaml | ||
| /// </summary> | ||
| public partial class App : Application | ||
| { | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| using System.Windows; | ||
|
|
||
| [assembly: ThemeInfo( | ||
| ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located | ||
| //(used if a resource is not found in the page, | ||
| // or application resource dictionaries) | ||
| ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located | ||
| //(used if a resource is not found in the page, | ||
| // app, or any theme specific resource dictionaries) | ||
| )] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| <Window x:Class="Synchronize_Trackball.MainWindow" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| xmlns:chart="clr-namespace:Syncfusion.UI.Xaml.Charts;assembly=Syncfusion.SfChart.WPF" | ||
| xmlns:local="clr-namespace:Synchronize_Trackball" | ||
| mc:Ignorable="d" | ||
| Title="MainWindow" Height="450" Width="800"> | ||
| <Grid> | ||
| <Grid.DataContext> | ||
| <local:DataGenerator/> | ||
| </Grid.DataContext> | ||
|
|
||
| <Grid.RowDefinitions> | ||
| <RowDefinition /> | ||
| <RowDefinition /> | ||
| </Grid.RowDefinitions> | ||
|
|
||
| <chart:SfChart x:Name="chart1" MouseMove="SfChart_MouseMove1" Header="FirstChart" Margin="5"> | ||
|
|
||
| <chart:SfChart.Behaviors> | ||
| <local:CustomTrackBallBehavior x:Name="behavior1"/> | ||
| </chart:SfChart.Behaviors> | ||
|
|
||
| <chart:SfChart.PrimaryAxis> | ||
| <chart:DateTimeAxis ShowTrackBallInfo="True" x:Name="axis" LabelFormat="MM/dd/yy" /> | ||
| </chart:SfChart.PrimaryAxis> | ||
|
|
||
| <chart:SfChart.SecondaryAxis> | ||
| <chart:NumericalAxis ShowTrackBallInfo="True" x:Name="secAxis"/> | ||
| </chart:SfChart.SecondaryAxis> | ||
|
|
||
| <chart:FastLineSeries x:Name="series1" XBindingPath="Date" YBindingPath="Value" | ||
| ItemsSource="{Binding DataCollection1}"/> | ||
|
|
||
| </chart:SfChart> | ||
|
|
||
| <chart:SfChart x:Name="chart2" MouseMove="SfChart_MouseMove2" Grid.Row="1" Grid.Column="0" Header="Second Chart" Margin="5"> | ||
|
|
||
| <chart:SfChart.Behaviors> | ||
| <local:CustomTrackBallBehavior x:Name="behavior2"/> | ||
| </chart:SfChart.Behaviors> | ||
|
|
||
| <chart:SfChart.PrimaryAxis> | ||
| <chart:DateTimeAxis ShowTrackBallInfo="True" LabelFormat="MM/dd/yy"/> | ||
| </chart:SfChart.PrimaryAxis> | ||
|
|
||
| <chart:SfChart.SecondaryAxis> | ||
| <chart:NumericalAxis ShowTrackBallInfo="True" /> | ||
| </chart:SfChart.SecondaryAxis> | ||
|
|
||
| <chart:FastLineSeries x:Name="series3" XBindingPath="Date" YBindingPath="Value" | ||
| ItemsSource="{Binding DataCollection2}"/> | ||
| </chart:SfChart> | ||
| </Grid> | ||
| </Window> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| using System.Collections.ObjectModel; | ||
| using Syncfusion.UI.Xaml.Charts; | ||
| using System.Text; | ||
| using System.Windows; | ||
| using System.Windows.Controls; | ||
| using System.Windows.Data; | ||
| using System.Windows.Documents; | ||
| using System.Windows.Input; | ||
| using System.Windows.Media; | ||
| using System.Windows.Media.Imaging; | ||
| using System.Windows.Navigation; | ||
| using System.Windows.Shapes; | ||
|
|
||
| namespace Synchronize_Trackball | ||
| { | ||
| /// <summary> | ||
| /// Interaction logic for MainWindow.xaml | ||
| /// </summary> | ||
| public partial class MainWindow : Window | ||
| { | ||
| public Point MousePoint | ||
| { | ||
| get; | ||
| set; | ||
| } | ||
|
|
||
| public MainWindow() | ||
| { | ||
| InitializeComponent(); | ||
| } | ||
|
|
||
| private void SfChart_MouseMove1(object sender, MouseEventArgs e) | ||
| { | ||
| // Taking the first chart position as reference to get the mouse point. | ||
| MousePoint = Mouse.GetPosition(behavior1.AdorningCanvas); | ||
| var chart1 = (sender as SfChart); | ||
|
|
||
| if (chart1.SeriesClipRect.Contains(MousePoint)) | ||
| { | ||
| // Generalizing position with respect to axis width. | ||
| MousePoint = new Point( | ||
| MousePoint.X - chart1.SeriesClipRect.Left, | ||
| MousePoint.Y - chart1.SeriesClipRect.Top); | ||
|
|
||
| behavior1.ActivateTrackball(MousePoint); | ||
| behavior2.ActivateTrackball(MousePoint); | ||
| } | ||
| else | ||
| { | ||
| behavior1.DeactivateTrackball(); | ||
| behavior2.DeactivateTrackball(); | ||
| } | ||
| } | ||
|
|
||
| private void SfChart_MouseMove2(object sender, MouseEventArgs e) | ||
| { | ||
| // Taking the second chart position as reference to get the mouse point. | ||
| MousePoint = Mouse.GetPosition(behavior2.AdorningCanvas); | ||
| var chart2 = (sender as SfChart); | ||
|
|
||
| if (chart2.SeriesClipRect.Contains(MousePoint)) | ||
| { | ||
| // Generalizing position with respect to axis width. | ||
| MousePoint = new Point( | ||
| MousePoint.X - chart2.SeriesClipRect.Left, | ||
| MousePoint.Y - chart2.SeriesClipRect.Top); | ||
|
|
||
| behavior1.ActivateTrackball(MousePoint); | ||
| behavior2.ActivateTrackball(MousePoint); | ||
| } | ||
| else | ||
| { | ||
| behavior1.DeactivateTrackball(); | ||
| behavior2.DeactivateTrackball(); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
||
| public class CustomTrackBallBehavior : ChartTrackBallBehavior | ||
VimalaThirumalaikumar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| public void ActivateTrackball(Point mousePoint) | ||
| { | ||
| IsActivated = true; | ||
| OnPointerPositionChanged(mousePoint); | ||
| } | ||
|
|
||
| public void DeactivateTrackball() | ||
| { | ||
| IsActivated = false; | ||
| } | ||
|
|
||
| // This method is overriden to improve perfomance by preventing the mouse position calculation which we have done already. | ||
| protected override void OnMouseMove(MouseEventArgs e) | ||
| { | ||
| } | ||
| } | ||
|
|
||
| public class Data | ||
| { | ||
| public Data(DateTime date, double value) | ||
| { | ||
| Date = date; | ||
| Value = value; | ||
| } | ||
|
|
||
| public DateTime Date | ||
| { | ||
| get; | ||
| set; | ||
| } | ||
|
|
||
| public double Value | ||
| { | ||
| get; | ||
| set; | ||
| } | ||
| } | ||
|
|
||
| public class DataGenerator | ||
| { | ||
| public int DataCount = 100; | ||
| private Random randomNumber; | ||
| public ObservableCollection<Data> DataCollection1 { get; set; } | ||
| public ObservableCollection<Data> DataCollection2 { get; set; } | ||
|
|
||
| public DataGenerator() | ||
| { | ||
| randomNumber = new Random(); | ||
| DataCollection1 = GenerateData(); | ||
| DataCollection2 = GenerateData(); | ||
| } | ||
|
|
||
| public ObservableCollection<Data> GenerateData() | ||
| { | ||
| ObservableCollection<Data> datas = new ObservableCollection<Data>(); | ||
| DateTime date = new DateTime(2020, 1, 1); | ||
| double value = 100; | ||
|
|
||
| for (int i = 0; i < this.DataCount; i++) | ||
| { | ||
| datas.Add(new Data(date, Math.Round(value, 2))); | ||
| date = date.Add(TimeSpan.FromDays(1)); | ||
|
|
||
| if (randomNumber.NextDouble() > .5) | ||
| { | ||
| value += randomNumber.NextDouble(); | ||
| } | ||
| else | ||
| { | ||
| value -= randomNumber.NextDouble(); | ||
| } | ||
| } | ||
|
|
||
| return datas; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>WinExe</OutputType> | ||
| <TargetFramework>net8.0-windows</TargetFramework> | ||
| <Nullable>enable</Nullable> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <UseWPF>true</UseWPF> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Syncfusion.SfChart.WPF" Version="*" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
This conversation was marked as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <PropertyGroup /> | ||
| <ItemGroup> | ||
| <ApplicationDefinition Update="App.xaml"> | ||
| <SubType>Designer</SubType> | ||
| </ApplicationDefinition> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <Page Update="MainWindow.xaml"> | ||
| <SubType>Designer</SubType> | ||
| </Page> | ||
| </ItemGroup> | ||
| </Project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| | ||
| Microsoft Visual Studio Solution File, Format Version 12.00 | ||
| # Visual Studio Version 17 | ||
| VisualStudioVersion = 17.12.35506.116 d17.12 | ||
| MinimumVisualStudioVersion = 10.0.40219.1 | ||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Synchronize_Trackball", "Synchronize_Trackball.csproj", "{2AE8056D-FC80-4398-A603-35E59086C4CA}" | ||
| EndProject | ||
| Global | ||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
| Debug|Any CPU = Debug|Any CPU | ||
| Release|Any CPU = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
| {2AE8056D-FC80-4398-A603-35E59086C4CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
| {2AE8056D-FC80-4398-A603-35E59086C4CA}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
| {2AE8056D-FC80-4398-A603-35E59086C4CA}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
| {2AE8056D-FC80-4398-A603-35E59086C4CA}.Release|Any CPU.Build.0 = Release|Any CPU | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| EndGlobal |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.