コード例 #1
0
        private void Lbl_OnTextChanged(object sender)
        {
            EditableTextBlock lbl = sender as EditableTextBlock;

            lbl.OnTextChanged -= Lbl_OnTextChanged;
            StackPanel stack       = lbl.Parent as StackPanel;
            String     fullPath    = stack.DataContext as String;
            String     oldName     = Path.GetFileNameWithoutExtension(fullPath);
            String     newFullPath = fullPath.Replace(oldName, lbl.Text);

            //Rename if file/dir does not exist

            if (File.Exists(fullPath) && !File.Exists(newFullPath))
            {
                File.Move(fullPath, newFullPath);
            }
            else if (Directory.Exists(fullPath) && !Directory.Exists(newFullPath))
            {
                Directory.Move(fullPath, newFullPath);
            }
            else
            {
                lbl.Text = oldName;
            }
            TreeViewItem item = stack.Parent as TreeViewItem;

            item.Focus();
        }
コード例 #2
0
        /// <summary>
        /// Создание объекта Header для элемента TreeView
        /// </summary>
        /// <param name="elem"></param>
        /// <returns></returns>
        private object CreateHeader(ProjectElementBase elem)
        {
            StackPanel panel = new StackPanel();

            panel.Orientation = Orientation.Horizontal;
            BitmapImage b_img = new BitmapImage(new Uri(elem.Icon, UriKind.Relative));
            Image       img   = new Image()
            {
                Source = b_img, Width = 16, Height = 16,
            };
            EditableTextBlock text = new EditableTextBlock()
            {
                Text = elem.Caption
            };

            text.Tag = elem;
            elem.Tag = panel;

            text.PreviewMouseDoubleClick += new MouseButtonEventHandler(TreeViewIcon_PreviewMouseDoubleClick);
            //text.PreviewMouseDoubleClick += new MouseButtonEventHandler(EditableTextBlock_PreviewMouseDoubleClick);
            text.OnIsInEditModeChanged += new EditableTextBlock.OnIsInEditModeChangedDelegate(text_OnIsInEditModeChanged);
            panel.Children.Add(img);
            panel.Children.Add(text);
            panel.ContextMenu = elem.CreateElementContextMenu(this);
            return(panel);
        }
コード例 #3
0
        private void SetCurrentItemInEditMode(bool EditMode)
        {
            // Make sure that the SelectedItem is actually a TreeViewItem
            // and not null or something else
            if (ListViewMain.SelectedItem is TreeViewItem)
            {
                TreeViewItem tvi = ListViewMain.SelectedItem as TreeViewItem;

                My_VariableBindingData data = tvi.Header as My_VariableBindingData;
                if ((data != null) && (data.Variable.IsEditableName == true))
                {
                    // Also make sure that the TreeViewItem
                    // uses an EditableTextBlock as its header
                    if (tvi.Header is EditableTextBlock)
                    {
                        EditableTextBlock etb = tvi.Header as EditableTextBlock;

                        // Finally make sure that we are
                        // allowed to edit the TextBlock
                        if (etb.IsEditable)
                        {
                            etb.IsInEditMode = EditMode;
                        }
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>Check if the <see cref="CommandBindingEditExecuted"/> function can be executed in the current context.</summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An <see cref="CanExecuteRoutedEventArgs"/> that contains the event data.</param>
        private void CommandBindingEditCanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            TreeView          source    = e.Source as TreeView;
            EditableTextBlock textBlock = e.OriginalSource as EditableTextBlock;

            e.CanExecute = source != null && textBlock != null;
        }
コード例 #5
0
        private void OnTextChanged(object sender, RoutedEventArgs e)
        {
            EditableTextBlock   Ctrl  = (EditableTextBlock)sender;
            StringPropertyEntry Entry = (StringPropertyEntry)Ctrl.DataContext;

            Entry.UpdateText(Ctrl.Text);
        }
コード例 #6
0
        private void OnItemEditing(object sender, EventArgs e)
        {
            EditableTextBlock block = (EditableTextBlock)sender;
            TranscriptEntry   entry = block.DataContext as TranscriptEntry;

            if (entry != null)
            {
                TranscriptView.SelectedItem = entry;
            }
        }
コード例 #7
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _Part_Header = Template.FindName("PART_Header", this) as EditableTextBlock;
            if (null != _Part_Header)
            {
                _Part_Header.MouseDown += _Part_Header_MouseDown;;
            }
        }
コード例 #8
0
        protected override EditableTextBlock buildEditableTextBlock()
        {
            var newEditableTextBlock = new EditableTextBlock();

            newEditableTextBlock.TextWrapping = TextWrapping.NoWrap;
            newEditableTextBlock.AcceptsReturn = false;
            newEditableTextBlock.Background = new SolidColorBrush(Colors.Transparent);
            newEditableTextBlock.Editable = true;
            return newEditableTextBlock;
        }
コード例 #9
0
        public EditableTextBlockAdorner( EditableTextBlock adornedElement )
            : base(adornedElement)
        {
            myTextBlock = adornedElement;

            myTextBox = CreateTextBox( adornedElement );

            myCollection = new VisualCollection( this );
            myCollection.Add( myTextBox );
        }
コード例 #10
0
        /// <summary>
        /// Edit the current <see cref="IHostfileEntry"/> object.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An <see cref="ExecutedRoutedEventArgs"/> that contains the event data.</param>
        private void CommandBindingEditExecuted(object sender, ExecutedRoutedEventArgs e)
        {
            TreeView          source    = e.Source as TreeView;
            EditableTextBlock textBlock = e.OriginalSource as EditableTextBlock;

            if (source != null && textBlock != null)
            {
                textBlock.IsInEditMode = !textBlock.IsInEditMode;
            }
        }
コード例 #11
0
        protected override EditableTextBlock buildEditableTextBlock()
        {
            var newEditableTextBlock = new EditableTextBlock();

            newEditableTextBlock.TextWrapping = TextWrapping.NoWrap;
            newEditableTextBlock.AcceptsReturn = false;
            newEditableTextBlock.Background = new SolidColorBrush(Colors.Transparent);
            newEditableTextBlock.Editable = true;
            return newEditableTextBlock;
        }
コード例 #12
0
ファイル: MainWindow.xaml.cs プロジェクト: Dreyark/Soundboard
 private void miDelete_Click(object sender, RoutedEventArgs e)
 {
     if (temporarySound != null)
     {
         SoundVM.OnSoundDelete(temporarySound);
         temporarySound    = null;
         editableTextBlock = null;
         RefreshListOfSounds();
     }
 }
コード例 #13
0
        protected override EditableTextBlock buildEditableTextBlock()
        {
            var newEditableTextBlock = new EditableTextBlock();

            newEditableTextBlock.TextWrapping  = TextWrapping.WrapWithOverflow;
            newEditableTextBlock.AcceptsReturn = true;
            newEditableTextBlock.Background    = new SolidColorBrush(Colors.LightBlue);
            newEditableTextBlock.Padding       = new Thickness(5, 0, 5, 0);
            newEditableTextBlock.Editable      = true;
            return(newEditableTextBlock);
        }
コード例 #14
0
ファイル: MainWindow.xaml.cs プロジェクト: Dreyark/Soundboard
 public void TextBox_LostFocus(object sender, RoutedEventArgs e)
 {
     if (editableTextBlock != null)
     {
         string Name = editableTextBlock.Text;
         SoundVM.OnTitleChange(temporarySound.FilePath, Name);
         temporarySound    = null;
         editableTextBlock = null;
         RefreshListOfSounds();
     }
 }
コード例 #15
0
        protected override EditableTextBlock buildEditableTextBlock()
        {
            var newEditableTextBlock = new EditableTextBlock();

            newEditableTextBlock.TextWrapping = TextWrapping.WrapWithOverflow;
            newEditableTextBlock.AcceptsReturn = true;
            newEditableTextBlock.Background = new SolidColorBrush(Colors.LightBlue);
            newEditableTextBlock.Padding = new Thickness(5, 0, 5, 0);
            newEditableTextBlock.Editable = true;
            return newEditableTextBlock;
        }
コード例 #16
0
 private void StartRename()
 {
     if (fileTree.SelectedItem != null)
     {
         TreeViewItem      item  = fileTree.SelectedItem as TreeViewItem;
         StackPanel        stack = item.Header as StackPanel;
         EditableTextBlock lbl   = stack.Children[1] as EditableTextBlock;
         item.IsSelected    = false;
         lbl.IsInEditMode   = true;
         lbl.OnTextChanged += Lbl_OnTextChanged;
     }
 }
コード例 #17
0
        private void Rename_Click(object sender, RoutedEventArgs e)
        {
            MenuItem mi = sender as MenuItem;
            long     id = 0;

            long.TryParse(mi.Uid, out id);
            //lstHierarchy.SelectedItem获取的是绑定的Actor数据
            ListBoxItem       lbi      = lstHierarchy.ItemContainerGenerator.ContainerFromIndex(lstHierarchy.SelectedIndex) as ListBoxItem;
            EditableTextBlock edtActor = ControlUtils.GetChildObject <EditableTextBlock>(lbi, "edtActor");

            edtActor.PrepareRename();
        }
コード例 #18
0
        private void TreeViewIcon_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            EditableTextBlock etb = sender as EditableTextBlock;

            if (etb != null)
            {
                ProjectElementBase elem = etb.Tag as ProjectElementBase;
                if (elem != null)
                {
                    core.OpenNewWindow(elem);
                }
            }
        }
コード例 #19
0
 public EditableTextBlockAdorner(EditableTextBlock adornedElement)
     : base(adornedElement)
 {
     _collection = new VisualCollection(this);
     _textBox = new TextBox();
     _textBlock = adornedElement;
     Binding binding = new Binding("Text") {Source = adornedElement};
     _textBox.SetBinding(TextBox.TextProperty, binding);
     _textBox.AcceptsReturn = true;
     _textBox.MaxLength = adornedElement.MaxLength;
     _textBox.KeyUp += _textBox_KeyUp;
     _collection.Add(_textBox);
 }
コード例 #20
0
        public void Setup()
        {
            _control = new EditableTextBlock
            {
                Style = StyleHelper.Load <EditableTextBlock>()
            };
            _control.ApplyTemplate();

            var type = typeof(EditableTextBlock);

            _textBox   = (EditorTextBox)type.GetField("_textBox", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(_control);
            _presenter = (MarkdownPresenter)type.GetField("_presenter", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(_control);
        }
コード例 #21
0
        public void TestApplyTemplate()
        {
            var control = new EditableTextBlock
            {
                Style = StyleHelper.Load <EditableTextBlock>(),
                Text  = "Foobar"
            };

            control.ApplyTemplate();
            var type      = typeof(EditableTextBlock);
            var presenter = (MarkdownPresenter)type.GetField("_presenter", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(control);

            presenter.Markdown.Should().Be("Foobar");
        }
コード例 #22
0
        private void EditableTextBlock_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            EditableTextBlock etb = sender as EditableTextBlock;

            if (etb != null)
            {
                // Finally make sure that we are
                // allowed to edit the TextBlock
                if (etb.IsEditable)
                {
                    etb.IsInEditMode = true;
                }
            }
        }
コード例 #23
0
 void text_OnIsInEditModeChanged(EditableTextBlock sender, bool IsEditable)
 {
     if (IsEditable == false)
     {
         ProjectElementBase elem = (sender.Tag) as ProjectElementBase;
         try
         {
             elem.Caption = sender.Text;
         }
         catch (Exception ex)
         {
             sender.Text = elem.Caption;
             Schematix.Core.Logger.Log.Error("OnCaptionChange error.", ex);
             System.Windows.MessageBox.Show(string.Format("Could not rename file.\n", ex.Message), "File system error ocurred", System.Windows.MessageBoxButton.OK);
         }
     }
 }
コード例 #24
0
        private TextBox CreateTextBox( EditableTextBlock adornedElement )
        {
            var textBox = new TextBox();

            Binding binding = new Binding( "Text" )
            {
                Source = adornedElement,
                UpdateSourceTrigger = UpdateSourceTrigger.Explicit
            };
            textBox.SetBinding( TextBox.TextProperty, binding );

            textBox.AcceptsReturn = true;
            textBox.MaxLength = adornedElement.MaxLength;
            textBox.KeyUp += myTextBox_KeyUp;
            textBox.LostFocus += myTextBox_LostFocus;
            textBox.SelectAll();

            return textBox;
        }
コード例 #25
0
 private void EditableTextBlock_SourceUpdated(object sender, DataTransferEventArgs e)
 {
     try
     {
         EditableTextBlock activeTB = sender as EditableTextBlock;
         object            Node     = activeTB.DataContext;
         if (Node != null)
         {
             if (Node is Group)
             {
                 (Node as Group).Save();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "EditableTextBlock_SourceUpdated", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
コード例 #26
0
        private void EditableTextBlock_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            EditableTextBlock etb = sender as EditableTextBlock;

            if (etb != null)
            {
                // Make sure that the SelectedItem is actually a TreeViewItem
                // and not null or something else
                if (ListViewMain.SelectedItem is TreeViewItem)
                {
                    TreeViewItem           tvi  = ListViewMain.SelectedItem as TreeViewItem;
                    My_VariableBindingData data = tvi.Header as My_VariableBindingData;
                    if ((data != null) && (data.Variable.IsEditableName == true))
                    {
                        // Finally make sure that we are
                        // allowed to edit the TextBlock
                        if (etb.IsEditable)
                        {
                            etb.IsInEditMode = true;
                        }
                    }
                }
            }
        }
コード例 #27
0
 private void TreeViewItemMenuFlyout_Opened(object sender, object e)
 {
     RightClickedTreeViewItemEditableTextBlock = ((sender as MenuFlyout).Target as WinUI.TreeViewItem).Content as EditableTextBlock;
 }
コード例 #28
0
        private void OnTextMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            EditableTextBlock Ctrl = (EditableTextBlock)sender;

            Ctrl.IsEditing = true;
        }
コード例 #29
0
ファイル: MainWindow.xaml.cs プロジェクト: Dreyark/Soundboard
 private void TextBox_MouseRightClick(object sender, MouseButtonEventArgs e)
 {
     editableTextBlock = (EditableTextBlock)sender;
     editableTextBlock.routedEvents.Add(TextBox_LostFocus);
     temporarySound = SoundVM.Sounds.Find(x => x.Name == (string)editableTextBlock.Text);
 }
コード例 #30
0
        private object CreateItem(string filePath)
        {
            if (Directory.Exists(filePath)) //dir
            {
                String dirName = new DirectoryInfo(filePath).Name;

                StackPanel stack = new StackPanel();
                stack.Orientation = Orientation.Horizontal;
                stack.Height      = 18;
                Image image = new Image();
                image.Source = new BitmapImage(new Uri("pack://application:,,/icons/assets/dir.png"));
                EditableTextBlock lbl = new EditableTextBlock {
                    Text = dirName
                };
                stack.Children.Add(image);
                stack.Children.Add(lbl);
                stack.DataContext = filePath;

                TreeViewItem item = new TreeViewItem {
                    Header = stack
                };
                foreach (object i in CreateTree(filePath))
                {
                    item.Items.Add(i);
                }

                return(item);
            }
            else if (File.Exists(filePath))
            {
                String fileName = Path.GetFileNameWithoutExtension(filePath);
                ThomasEngine.Resources.AssetTypes assetType = ThomasEngine.Resources.GetResourceAssetType(filePath);
                if (assetType == ThomasEngine.Resources.AssetTypes.UNKNOWN)
                {
                    return(null);
                }
                StackPanel stack = new StackPanel();
                stack.Orientation = Orientation.Horizontal;
                stack.Height      = 18;

                ImageSource source;
                if (assetType == ThomasEngine.Resources.AssetTypes.TEXTURE2D)
                {
                    source = new BitmapImage(new Uri(Path.GetFullPath(filePath)));
                }
                else
                {
                    source = assetImages[assetType];
                }

                Image image = new Image {
                    Source = source
                };

                EditableTextBlock lbl = new EditableTextBlock {
                    Text = fileName
                };
                stack.Children.Add(image);
                stack.Children.Add(lbl);
                stack.DataContext = filePath;

                return(new TreeViewItem {
                    Header = stack, DataContext = ThomasEngine.Resources.Load(filePath)
                });
            }
            return(null);
        }
コード例 #31
0
        void ZoomIn(int x, int y)
        {
            zoomCanvas = new KEAPCanvas();
            zoomCanvas.Width = AudienceCanvas.Width;
            zoomCanvas.Height = AudienceCanvas.Height;
            zoomCanvas.Background = null;

            Rectangle rec_BG = new Rectangle()
            {
                Width = SystemParameters.WorkArea.Width,
                Height = SystemParameters.PrimaryScreenHeight,
                Stroke = null,
                Fill = AudienceCanvas.Background
            };
            Canvas.SetLeft(rec_BG, -(SystemParameters.WorkArea.Width * x / 8)); //* (120 / 96)
            Canvas.SetTop(rec_BG, -(WindowSettings.resolution_Height * y / 8)); //* (120 / 96)
            zoomCanvas.Children.Add(rec_BG);

            UIElement[] copyuiele = new UIElement[AudienceCanvas.Children.Count];
            AudienceCanvas.Children.CopyTo(copyuiele, 0);
            foreach (UIElement ele in copyuiele)
            {
                if (ele is EditableTextBlock)
                {
                    EditableTextBlock copyele = ele as EditableTextBlock;
                    EditableTextBlock textblock = new EditableTextBlock()
                    {
                        Text = copyele.Text,
                        Width = copyele.Width,
                        Height = copyele.Height,
                        FontSize = copyele.FontSize,
                        TextAlignment = copyele.TextAlignment,
                        Effect = copyele.Effect,
                        FontWeight = copyele.FontWeight,
                        FontFamily = copyele.FontFamily,
                        Background = copyele.Background,
                        Foreground = copyele.Foreground,
                        TextDecorations = copyele.TextDecorations
                    };
                    Canvas.SetLeft(textblock,Canvas.GetLeft(copyele));
                    Canvas.SetTop(textblock,Canvas.GetTop(copyele));

                    double x1 = Canvas.GetLeft(ele),
                        y1 = Canvas.GetTop(ele);

                    Canvas.SetLeft(textblock, x1 - (SystemParameters.PrimaryScreenWidth * x / 8));
                    Canvas.SetTop(textblock, y1 - (SystemParameters.PrimaryScreenHeight * y / 8));

                    zoomCanvas.Children.Add(textblock);
                }
                else if (ele is Polygon)
                {
                    Polygon copyele = ele as Polygon;
                    Polygon polygon = new Polygon()
                    {
                        Points = copyele.Points,
                        Stroke = copyele.Stroke,
                        StrokeThickness = copyele.StrokeThickness,
                        Fill = copyele.Fill
                    };

                    Point[] copy_points = new Point[polygon.Points.Count];
                    PointCollection copy_collection = new PointCollection();
                    polygon.Points.CopyTo(copy_points, 0);
                    for (int i = 0; i < polygon.Points.Count; i++)
                    {
                        copy_points[i].X = copy_points[i].X - (SystemParameters.WorkArea.Width * x / 8);
                        copy_points[i].Y = copy_points[i].Y - (SystemParameters.PrimaryScreenHeight * y / 8);
                        copy_collection.Add(copy_points[i]);
                    }
                    polygon.Points = copy_collection;

                    zoomCanvas.Children.Add(polygon);
                }
                else if (ele is Line)
                {
                    Line copyele = ele as Line;
                    Line line = new Line()
                    {
                        X1 = copyele.X1,
                        Y1 = copyele.Y1,
                        X2 = copyele.X2,
                        Y2 = copyele.Y2,
                        Stroke = copyele.Stroke,
                        StrokeThickness = copyele.StrokeThickness,
                    };

                    line.X1 = ((Line)ele).X1 - (SystemParameters.WorkArea.Width * x / 8);
                    line.Y1 = ((Line)ele).Y1 - (SystemParameters.PrimaryScreenHeight * y / 8);
                    line.X2 = ((Line)ele).X2 - (SystemParameters.WorkArea.Width * y / 8);
                    line.Y2 = ((Line)ele).Y2 - (SystemParameters.PrimaryScreenHeight * y / 8);

                    zoomCanvas.Children.Add(line);
                }
                else if (ele is Image)
                {
                    Image copyele = ele as Image;
                    Image image = new Image()
                    {
                        Source = copyele.Source,
                        Width = copyele.Width,
                        Height = copyele.Height,
                    };
                    Canvas.SetLeft(image, Canvas.GetLeft(copyele));
                    Canvas.SetTop(image, Canvas.GetTop(copyele));

                    double x1 = Canvas.GetLeft(ele),
                        y1 = Canvas.GetTop(ele);

                    Canvas.SetLeft(image, x1 - (SystemParameters.WorkArea.Width * x / 8));
                    Canvas.SetTop(image, y1 - (SystemParameters.PrimaryScreenHeight * y / 8));

                    zoomCanvas.Children.Add(image);
                }
                else if (ele is Rectangle)
                {
                    Rectangle copyele = ele as Rectangle;
                    Rectangle rectangle = new Rectangle()
                    {
                        Width = copyele.Width,
                        Height = copyele.Height,
                        Fill = copyele.Fill,
                        Stroke = copyele.Stroke,
                        StrokeThickness = copyele.StrokeThickness
                    };
                    Canvas.SetLeft(rectangle, Canvas.GetLeft(copyele));
                    Canvas.SetTop(rectangle, Canvas.GetTop(copyele));

                    double x1 = Canvas.GetLeft(ele),
                        y1 = Canvas.GetTop(ele);

                    Canvas.SetLeft(rectangle, x1 - (SystemParameters.WorkArea.Width * x / 8));
                    Canvas.SetTop(rectangle, y1 - (SystemParameters.PrimaryScreenHeight * y / 8));

                    zoomCanvas.Children.Add(rectangle);
                }
                else if (ele is Ellipse)
                {
                    Ellipse copyele = ele as Ellipse;
                    Ellipse ellipse = new Ellipse()
                    {
                        Width = copyele.Width,
                        Height = copyele.Height,
                        Fill = copyele.Fill,
                        Stroke = copyele.Stroke,
                        StrokeThickness = copyele.StrokeThickness
                    };
                    Canvas.SetLeft(ellipse, Canvas.GetLeft(copyele));
                    Canvas.SetTop(ellipse, Canvas.GetTop(copyele));

                    double x1 = Canvas.GetLeft(ele),
                        y1 = Canvas.GetTop(ele);

                    Canvas.SetLeft(ellipse, x1 - (SystemParameters.WorkArea.Width * x / 8));
                    Canvas.SetTop(ellipse, y1 - (SystemParameters.PrimaryScreenHeight * y / 8));

                    zoomCanvas.Children.Add(ellipse);
                }
            }

            AudienceGrid.Background = null;
            zoomCanvas.UpdateLayout();
            zoom_img = new Image();

            FrameworkElement TargetVisual = zoomCanvas as FrameworkElement;
            int width, height;
            TargetVisual.Arrange(new Rect(0, 0, 0, 0));
            width = (int)TargetVisual.ActualWidth;
            height = (int)TargetVisual.ActualHeight;
            if(TargetVisual.RenderTransform!=null)
            {
                Rect bounds = new Rect(0, 0, TargetVisual.ActualWidth, TargetVisual.ActualHeight);
                bounds = TargetVisual.RenderTransform.TransformBounds(bounds);
                TargetVisual.Arrange(new Rect(-bounds.Left, -bounds.Top, width, height));
                width = (int)bounds.Width;
                height = (int)bounds.Height;
            }

            //RenderTargetBitmap zoom_rtb = new RenderTargetBitmap(width/4 + 402, height/4 + 237, 96d, 96d, System.Windows.Media.PixelFormats.Default);
            //RenderTargetBitmap zoom_rtb = new RenderTargetBitmap(width/4, height/4, 96d, 96d, System.Windows.Media.PixelFormats.Default);
            RenderTargetBitmap zoom_rtb = new RenderTargetBitmap(((width/4)+402), ((height/4)+237), 96d, 96d, System.Windows.Media.PixelFormats.Default);
            AudienceGrid.Children.Insert(0, zoomCanvas);
            AudienceGrid.Children.Remove(AudienceCanvas);
            zoomCanvas.UpdateLayout();
            AudienceGrid.UpdateLayout();
            zoom_rtb.Render(TargetVisual);
            zoom_img.Source = zoom_rtb;
            zoom_img.HorizontalAlignment = HorizontalAlignment.Stretch;
            zoom_img.VerticalAlignment = VerticalAlignment.Stretch;
            zoom_img.Stretch = Stretch.Fill;
            //AudienceGrid.Children.Remove(AudienceCanvas);
            zoom_img.Width = SystemParameters.WorkArea.Width;
            zoom_img.Height = SystemParameters.MaximizedPrimaryScreenHeight;

            AudienceGrid.Children.Add(zoom_img);

            AudienceGrid.Children.Remove(zoomCanvas);
            //AudienceGrid.Background = new ImageBrush(zoom_img.Source);
            //AudienceGrid.Background = new SolidColorBrush(Colors.Blue);
        }
コード例 #32
0
        public FullWindowForAudience(MainWindow main, FullWindowForPresentor pre)
        {
            main_View = main;
            pre_View = pre;
            AddKeyBindings();

            InitializeComponent();
            int i = 0;
            canvas_arr = new List<KEAPCanvas>();

            foreach (KEAPCanvas canvas in main.canvas_List)
            {
                bool ani_null = false;
                if (!main.animation_Dictionary.Keys.Contains(i)) ani_null = true;
                else animations = main.animation_Dictionary;
                List<Dictionary<int, string>> anilist = new List<Dictionary<int,string>>();
                if (ani_null)
                    anilist = null;
                else
                {
                //    if (i < animations.Count)
                    Dictionary<int, string>[] ani_arr = new Dictionary<int,string>[main.animation_Dictionary[i].Count];
                    //main.animation_Dictionary[i].CopyTo(animations);
                    main.animation_Dictionary[i].CopyTo(ani_arr);
                    for (int k = 0; k < main.animation_Dictionary[i].Count;k++)
                    {
                        Dictionary<int,string> tempdic = new Dictionary<int,string>();
                        tempdic.Add(ani_arr[k].Keys.First(),ani_arr[k].Values.First());
                        anilist.Add(tempdic);
                    }
                //    else
                //        anilist = null;
                }
                canvas_arr.Add(new KEAPCanvas());
                canvas_arr[i].Width = SystemParameters.WorkArea.Width;
                canvas_arr[i].Height = SystemParameters.PrimaryScreenHeight;
                canvas_arr[i].Background = canvas.Background;

                for (int j=0; j<main.canvas_List[i].Children.Count; j++)
                {
                    UIElement ele = main.canvas_List[i].Children[j];
                    if (ele is EditableTextBlock)
                    {
                        EditableTextBlock copyele = ele as EditableTextBlock;
                        EditableTextBlock textblock = new EditableTextBlock()
                        {
                            Text = copyele.Text,
                            Width = copyele.Width * (SystemParameters.WorkArea.Width / canvas.Width),
                            Height = copyele.Height * (SystemParameters.PrimaryScreenHeight / canvas.Height),
                            FontSize = copyele.FontSize,
                            TextAlignment = copyele.TextAlignment,
                            Effect = copyele.Effect,
                            FontWeight = copyele.FontWeight,
                            FontFamily = copyele.FontFamily,
                            Background = copyele.Background,
                            Foreground = copyele.Foreground,
                            TextDecorations = copyele.TextDecorations
                        };
                        Canvas.SetLeft(textblock, Canvas.GetLeft(copyele) * (SystemParameters.WorkArea.Width / canvas.Width) );
                        Canvas.SetTop(textblock, Canvas.GetTop(copyele) * (SystemParameters.PrimaryScreenHeight / canvas.Height) );

                        canvas_arr[i].Children.Add(textblock);
                    }
                    else if (ele is Polygon)
                    {
                        Polygon copyele = ele as Polygon;
                        Polygon polygon = new Polygon()
                        {
                            Points = copyele.Points,
                            Stroke = copyele.Stroke,
                            StrokeThickness = copyele.StrokeThickness,
                            Fill = copyele.Fill
                        };

                        Point[] copy_points = new Point[polygon.Points.Count];
                        PointCollection copy_collection = new PointCollection();
                        polygon.Points.CopyTo(copy_points, 0);
                        for (int p = 0; p < polygon.Points.Count; p++)
                        {
                            copy_points[p].X = copy_points[p].X * (SystemParameters.WorkArea.Width / canvas.Width) ;
                            copy_points[p].Y = copy_points[p].Y * (SystemParameters.PrimaryScreenHeight / canvas.Height) ;
                            copy_collection.Add(copy_points[p]);
                        }
                        polygon.Points = copy_collection;

                        canvas_arr[i].Children.Add(polygon);
                    }
                    else if (ele is Line)
                    {
                        Line copyele = ele as Line;
                        Line line = new Line()
                        {
                            X1 = copyele.X1 * (SystemParameters.WorkArea.Width / canvas.Width) ,
                            Y1 = copyele.Y1 * (SystemParameters.PrimaryScreenHeight / canvas.Height) ,
                            X2 = copyele.X2 * (SystemParameters.WorkArea.Width / canvas.Width) ,
                            Y2 = copyele.Y2 * (SystemParameters.PrimaryScreenHeight / canvas.Height) ,
                            Stroke = copyele.Stroke,
                            StrokeThickness = copyele.StrokeThickness,
                        };

                        canvas_arr[i].Children.Add(line);
                    }
                    else if (ele is Image)
                    {
                        Image copyele = ele as Image;
                        Image image = new Image()
                        {
                            Source = copyele.Source,
                            Width = copyele.Width * (SystemParameters.WorkArea.Width / canvas.Width) ,
                            Height = copyele.Height * (SystemParameters.PrimaryScreenHeight / canvas.Height)
                        };
                        Canvas.SetLeft(image, Canvas.GetLeft(copyele) * (SystemParameters.WorkArea.Width / canvas.Width) );
                        Canvas.SetTop(image, Canvas.GetTop(copyele) * (SystemParameters.PrimaryScreenHeight / canvas.Height) );

                        canvas_arr[i].Children.Add(image);
                    }
                    else if (ele is Rectangle)
                    {
                        Rectangle copyele = ele as Rectangle;
                        Rectangle rectangle = new Rectangle()
                        {
                            Width = copyele.Width * (SystemParameters.WorkArea.Width / canvas.Width) ,
                            Height = copyele.Height * (SystemParameters.PrimaryScreenHeight / canvas.Height) ,
                            Fill = copyele.Fill,
                            Stroke = copyele.Stroke,
                            StrokeThickness = copyele.StrokeThickness
                        };
                        Canvas.SetLeft(rectangle, Canvas.GetLeft(copyele) * (SystemParameters.WorkArea.Width / canvas.Width) );
                        Canvas.SetTop(rectangle, Canvas.GetTop(copyele) * (SystemParameters.PrimaryScreenHeight / canvas.Height) );

                        canvas_arr[i].Children.Add(rectangle);
                    }
                    else if (ele is Ellipse)
                    {
                        Ellipse copyele = ele as Ellipse;
                        Ellipse ellipse = new Ellipse()
                        {
                            Width = copyele.Width * (SystemParameters.WorkArea.Width / canvas.Width) ,
                            Height = copyele.Height * (SystemParameters.PrimaryScreenHeight / canvas.Height) ,
                            Fill = copyele.Fill,
                            Stroke = copyele.Stroke,
                            StrokeThickness = copyele.StrokeThickness
                        };
                        Canvas.SetLeft(ellipse, Canvas.GetLeft(copyele) * (SystemParameters.WorkArea.Width / canvas.Width) );
                        Canvas.SetTop(ellipse, Canvas.GetTop(copyele) * (SystemParameters.PrimaryScreenHeight / canvas.Height) );

                        canvas_arr[i].Children.Add(ellipse);
                    }
                    //canvas_arr[i].Measure(new Size(SystemParameters.WorkArea.Width, SystemParameters.MaximizedPrimaryScreenHeight));
                    //canvas_arr[i].Arrange(new Rect(0, 0, SystemParameters.WorkArea.Width, SystemParameters.MaximizedPrimaryScreenHeight));
                }
                if (anilist != null)
                {
                    foreach (Dictionary<int, string> dic in anilist)
                    {
                        string ani = dic[dic.Keys.First()];
                        if (ani.Contains("Bounds") || ani.Contains("Move") || ani.Contains("FadeIn")
                            || ani.Contains("Interlaced") || ani.Contains("Block") || ani.Contains("Circle") || ani.Contains("Radial") || ani.Contains("WaterFall"))
                        {
                            canvas_arr[i].Children[dic.Keys.First()].Visibility = Visibility.Collapsed;
                        }
                    }
                }
                i++;
            }

            /*
            for(i=0; i<main.animation_Dictionary.Count; i++)
            {
                animations.Add(i,new Dictionary<int,string>[main.animation_Dictionary[i].Count()]);
                main.animation_Dictionary[i].CopyTo(animations[i]);
            }*/
            DefaultPageNum = main.DefaultCanvasNum;
        }