Как перетащить на фасонный обработчик на основе тега xml, используя c# в wpf? - PullRequest
0 голосов
/ 07 февраля 2020

enter image description here

Синяя линия на изображении - это мой холст. Используя холст, я пытаюсь переместить большой палец (изображение в форме т) с помощью таймера , Теперь я использую таймер для запуска, так что на основе таймера мой обработчик движется. Но мне нужно автоматически перемещаться так же, как и перемещать позицию обработчика. когда перетаскивание завершено, мне нужно начать переход с того места, где я уронил свой обработчик.

Может ли кто-нибудь помочь мне добиться этого? `

My xml файл

<m_config>
<mixer_streams>
    <file in='0.0' path='d:\ahd_assets\images\A.png' interlace='' aspect_ratio='' scale_type='default' external_audio='' external_audio_offset='' preview.pull='false' img_stub='' img.default_duration='5' img.tone='' no_breaks='false' open_file.max_wait='10000' open_url.max_wait='10000' read_url.max_wait='3000' read_file.max_wait='3000' force_mpeg_tc='false' audio_track='0' video_track='0' subtitle_track='-1' ts_program='-1' network.buffer_min='1.0' network.buffer_max='10.0' network.rate_control='true' file.buffer_min='0.0' file.buffer_max='2.0' decode='auto' decode.fallback='false' out_point.mode='wait' mfreader.convert_format='true' output.10bit='false' file.max_forward_rate='4.0' stream_id='LA' start_timecode='' format_3d='default' right_eye_video='' in_preroll='1.0' tc_preroll='1.0' duration='5.0' ref_id='0x4CB41140' loop='true'>
        <info/>
        <video video_format='HD1080-29p' width='1920' height='-1080' rate='29.97003' pixel_format='ARGB32' aspect_ratio='16:9' interlace='progressive'/>
        <audio track_split=''/>
        <object imaudio.enabled='true' audio_channels='' audio_gain='' gpu.rgb_transform_matrix='' default_name='MFile' default_tracks='0' channels_per_track='0' internal.convert_frame='false' experimental.buffers='0' pause.fields='2' pause.use_reference='false' afilter='' scaling_quality='auto' crop='' mirror='' rotate='' overlay_rms='false' overlay_rms.pos='0.1' overlay_rms.color='green' overlay_waveform='false' overlay_waveform.pos='-0.3' overlay_waveform.color='' audio.variable_rate='true' audio.lufs='false' audio.lufs_state='' audio.lufs_channels='' audio.gain_normalization='false' gain_normalization.target_i='-23.0' gain_normalization.skip_frames='20.0' timecode.time_sync='0' timecode.offset='' mfconverter.enabled='true' format.set_default_pixelformat='true' mdelay.enabled='false' mdelay.live_preview='false' file.max_reverse_rate='2.0' gain_normalization.gating='-100.0' gain_normalization.loudness_type='rms' playback_rate='1.0' statistics.extended='' network.buffer_wait_kf='false' network.max_video_gap='80' file.buffer_wait_kf='false'/>
        <mitem_props stop_in='' stop_out='' pause_in='' pause_out='' video='true' audio='true' drop_frames='false' master='false' stream_id='LA'>
            <file/>
            <device/>
            <object/>
        </mitem_props>
    </file>
    <file in='0.0' path='d:\ahd_assets\images\B.png' interlace='' aspect_ratio='' scale_type='default' external_audio='' external_audio_offset='' preview.pull='false' img_stub='' img.default_duration='5' img.tone='' no_breaks='false' open_file.max_wait='10000' open_url.max_wait='10000' read_url.max_wait='3000' read_file.max_wait='3000' force_mpeg_tc='false' audio_track='0' video_track='0' subtitle_track='-1' ts_program='-1' network.buffer_min='1.0' network.buffer_max='10.0' network.rate_control='true' file.buffer_min='0.0' file.buffer_max='2.0' decode='auto' decode.fallback='false' out_point.mode='wait' mfreader.convert_format='true' output.10bit='false' file.max_forward_rate='4.0' stream_id='LB' start_timecode='' format_3d='default' right_eye_video='' in_preroll='1.0' tc_preroll='1.0' duration='5.0' ref_id='0x20A6A370' loop='true'>
        <info/>
        <video video_format='HD1080-29p' width='1920' height='-1080' rate='29.97003' pixel_format='ARGB32' aspect_ratio='16:9' interlace='progressive'/>
        <audio track_split=''/>
        <object imaudio.enabled='true' audio_channels='' audio_gain='' gpu.rgb_transform_matrix='' default_name='MFile' default_tracks='0' channels_per_track='0' internal.convert_frame='false' experimental.buffers='0' pause.fields='2' pause.use_reference='false' afilter='' scaling_quality='auto' crop='' mirror='' rotate='' overlay_rms='false' overlay_rms.pos='0.1' overlay_rms.color='green' overlay_waveform='false' overlay_waveform.pos='-0.3' overlay_waveform.color='' audio.variable_rate='true' audio.lufs='false' audio.lufs_state='' audio.lufs_channels='' audio.gain_normalization='false' gain_normalization.target_i='-23.0' gain_normalization.skip_frames='20.0' timecode.time_sync='0' timecode.offset='' mfconverter.enabled='true' format.set_default_pixelformat='true' mdelay.enabled='false' mdelay.live_preview='false' file.max_reverse_rate='2.0' gain_normalization.gating='-100.0' gain_normalization.loudness_type='rms' playback_rate='1.0' statistics.extended='' network.buffer_wait_kf='false' network.max_video_gap='80' file.buffer_wait_kf='false'/>
        <mitem_props stop_in='' stop_out='' pause_in='' pause_out='' video='true' audio='true' drop_frames='false' master='false' stream_id='LB'>
            <file/>
            <device/>
            <object/>
        </mitem_props>
    </file>
</mixer_streams>
<m_scenes active_scene='New_18'>
    <m_scene name='New_18'>
        <scene_3d view_angle='45.0' show='true'>
            <group id='ahd_trn' duration='2' fixed='0' swap='1' reverse='1'>
                <group id='virtual'>
                    <object id='object_000' src='d:\ahd_assets\3ds\07126\RINGS EDITED.3DS' y='0.100' z='1' r='0' rv='50' show='true' LayerA.png='LA' LayerB.png='LB'/>
                    <video id='video_A_OUT' stream_id='LA' stream_idx='-1' audio_gain='-80' show='true' z='1.000' w='0.171' x='0'/>
                    <video id='video_B_in' stream_id='LB' stream_idx='-1' audio_gain='-80' z='1.000' w='0.171' x='1.000' show='true'/>
                </group>
            </group>
            <camera/>
        </scene_3d>
        <view>
            <view id='t_00' duration='3.0' hold='0.0' reverse='0'>
                <video show='true' x='-1.000' target_id='scene_3d::ahd_trn::virtual::video_A_OUT'/>
                <video show='true' rv='0' z='1.100' y='0.100' target_id='scene_3d::ahd_trn::virtual::object_000'/>
            </view>
            <view id='t_01' duration='20.0' hold='0.0' reverse='0'>
                <video show='true' rh='360' y='0.100' z='1.050' target_id='scene_3d::ahd_trn::virtual::object_000'/>
            </view>
            <view id='t_02' duration='3.0' hold='0.0' reverse='0'>
                <video show='true' rv='50' z='1' y='0.100' target_id='scene_3d::ahd_trn::virtual::object_000'/>
                <video show='true' x='0' target_id='scene_3d::ahd_trn::virtual::video_B_in'/>
            </view>
            <view id='t_03' duration='0.0' hold='0.0' reverse='1'>
                <object target_id='scene_3d::ahd_trn::virtual::object_000' show='true' y='0.100' z='1.000' rv='50' rh='0'/>
                <video target_id='scene_3d::ahd_trn::virtual::video_A_OUT' show='true' x='-1.000'/>
                <video target_id='scene_3d::ahd_trn::virtual::video_B_in' show='true' x='0.000' z='1.000' w='0.171'/>
            </view>
            <view id='t_04' duration='3.0' hold='0.0' reverse='1'>
                <object target_id='scene_3d::ahd_trn::virtual::object_000' show='true' y='0.100' z='1.000' rv='0'/>
                <video show='true' x='1.000' z='1.000' w='0.171' target_id='scene_3d::ahd_trn::virtual::video_B_in'/>
            </view>
            <view id='t_05' duration='20.0' hold='0.0' reverse='1'>
                <object target_id='scene_3d::ahd_trn::virtual::object_000' show='true' rh='360' y='0.100' z='1.050'/>
            </view>
            <view id='t_06' duration='3.0' hold='0.0' reverse='1'>
                <video show='true' x='0.000' z='1.000' w='0.171' target_id='scene_3d::ahd_trn::virtual::video_A_OUT'/>
                <object show='true' rv='50' z='1.000' y='0.100' target_id='scene_3d::ahd_trn::virtual::object_000'/>
            </view>
        </view>
        <background/>
        <foreground parallax-shift='0.05'/>
    </m_scene>
</m_scenes>

`

В этом xml у меня есть тег просмотра внизу. Как связать мой тег с обработчиком перетаскивания. например, view id = t_06, если я перетаскиваю изображение t в своем обработчике вниз, это должно дать мне значение некоторой переменной a = t_06. если я двигаюсь вверх с помощью левой кнопки мыши, это должно дать a = t_04 или t_03 вот так.

wpf xaml код для t-обработчика

 <DockPanel Grid.Row="1" Background="#FF2C2C2C">
        <Grid x:Name="pnlM" Width="13" Panel.ZIndex="0" Margin="44.5,0,0,0">
            <Grid.Background>
                <ImageBrush ImageSource="/Mep_Agh;component/Resources/handle-stripe-M.png"/>
            </Grid.Background>
            <Grid.RowDefinitions >
                <RowDefinition Height="15"></RowDefinition>
                <RowDefinition Height="15"></RowDefinition>
                <RowDefinition Height="15"></RowDefinition>
                <RowDefinition Height="15"></RowDefinition>
                <RowDefinition Height="15"></RowDefinition>
                <RowDefinition Height="15"></RowDefinition>
                <RowDefinition Height="15"></RowDefinition>
                <RowDefinition Height="15"></RowDefinition>
                <RowDefinition Height="15"></RowDefinition>
                <RowDefinition Height="15"></RowDefinition>
            </Grid.RowDefinitions>

        </Grid>
        <!--<StackPanel x:Name="pnlM" Width="13" Panel.ZIndex="0" Margin="44.5,0,0,0" Orientation="Horizontal">
            <StackPanel.Background>
                <ImageBrush ImageSource="/Mep_Agh;component/Resources/handle-stripe-M.png"/>
            </StackPanel.Background>

        </StackPanel>-->
        <!--<ScrollViewer Height="Auto" Width="Auto" PreviewMouseWheel="ScrollViewer_PreviewMouseWheel"  >-->
            <Canvas x:Name="MyCanvas"  >

            <Image  x:Name="btnH" Height="27" Width="60" Canvas.Left="-36"  Source="/Mep_Agh;component/Resources/handle.png"
                    MouseMove="Control_MouseMove" MouseLeftButtonDown="Control_MouseLeftButtonDown" MouseLeftButtonUp="Control_MouseLeftButtonUp" AllowDrop="True"  >
            </Image>
            <!--<Button x:Name="btnH" Height="27" Style="{StaticResource MyButton}" VerticalAlignment="Top" Width="60" BorderBrush="{x:Null}" Panel.ZIndex="1" HorizontalAlignment="Left" DockPanel.Dock="Top" Canvas.Left="-37" Canvas.Top="1" MouseMove="Control_MouseMove" MouseLeftButtonDown="Control_MouseLeftButtonDown" MouseLeftButtonUp="Control_MouseLeftButtonUp">
                    <Button.Background>
                        <ImageBrush ImageSource="/Mep_Agh;component/Resources/joy_thumb.bmp" Stretch="Uniform"/>
                    </Button.Background>
                </Button>-->
            </Canvas>
        <!--</ScrollViewer>-->
    </DockPanel>

Определения строк, которые я создал соответствует количеству тегов просмотра.

1 Ответ

0 голосов
/ 12 февраля 2020

Я получил индекс просмотра, и я также смог выполнить свою задачу. Ниже приведен код

   Point currentPosition = e.GetPosition(this.Parent as UIElement);
        r = Convert.ToInt32(currentPosition.Y);
       // MessageBox.Show(Convert.ToString(r));

        int tr = MPHelper.mTransitionViewCount;
        int start = 26;
        int end = 156;
        int nt = end / tr;
        start = start + nt;
        //if (tr == 6)
        //{

            if ((r < 36) )
            {
                _rindex = 1; /*Helper.Master.efx_Run_Click(sender, e);*/ Helper.Master.efx_Run_Click1(_rindex);
            Helper.Master.efxThread = new Thread(() => Helper.Master.ParentThreadII1(_rindex)); Helper.Master.efxThread.Start();r1 = -7;
            }
            if ((r < 52) && (r > 36))
            {
                _rindex = 2;/*Helper.Master.efx_Run_Click(sender, e);*/ Helper.Master.efx_Run_Click1(_rindex); 
            Helper.Master.efxThread = new Thread(() => Helper.Master.ParentThreadII1(_rindex)); Helper.Master.efxThread.Start();r1 = -8;
            }
            if ((r < 78) && (r>52))
            {
               _rindex = 3;Canvas.SetTop(btnH, Canvas.GetTop(btnH)); /*Helper.Master.efx_Run_Click(sender, e);*/ Helper.Master.efx_Run_Click1(_rindex); 
            Helper.Master.efxThread = new Thread(() => Helper.Master.ParentThreadII1(_rindex)); Helper.Master.efxThread.Start();r1 = -51;
        }
            if ((r < 104) && (r>78))
            {
                _rindex = 4; /*Helper.Master.efx_Run_Click(sender, e);*/ Helper.Master.efx_Run_Click1(_rindex);
            Helper.Master.efxThread = new Thread(() => Helper.Master.ParentThreadII1(_rindex)); Helper.Master.efxThread.Start();r1 = -21;
            }
            if ((r < 130) && (r>104))
            {
                _rindex = 5; /*Helper.Master.efx_Run_Click(sender, e);*/ Helper.Master.efx_Run_Click1(_rindex);
            Helper.Master.efxThread = new Thread(() => Helper.Master.ParentThreadII1(_rindex)); Helper.Master.efxThread.Start();r1 = -23;
            }
            if ((r < 156) && (r>130))
            {
                _rindex = 6; /*Helper.Master.efx_Run_Click(sender, e);*/ Helper.Master.efx_Run_Click1(_rindex); 
            Helper.Master.efxThread = new Thread(() => Helper.Master.ParentThreadII1(_rindex)); Helper.Master.efxThread.Start();r1 = -25;
            }


        if (count > MPHelper.mTransitionViewCount)
        {
            count = 0;
        }
        isDragging = false;
        var draggable = sender as Image;
        draggable.ReleaseMouseCapture();
...