Window win; // XAML��� ������ window

        #endregion Fields

        #region Constructors

        // ������.
        public XamlCruncher()
        {
            // File open�� save ��ȭ���ڸ� ���� ����
            strFilter = "XAML Files(*.xaml)|*.xaml|All Files(*.*)|*.*";

            // DockPanel�� ã���� �װͿ��� TextBox�� �����Ѵ�
            DockPanel dock = txtbox.Parent as DockPanel;
            dock.Children.Remove(txtbox);

            // 3���� ���� ������ ������ Gred�� �����ϰ� ũ��� 0���� �������
            //  Grid ���� ������ �����Ǵ� ������ ǥ ������ �����մϴ�
            Grid grid = new Grid();
            dock.Children.Add(grid);

            for (int i = 0; i < 3; i++)
            {
                RowDefinition rowdef = new RowDefinition();
                rowdef.Height = new GridLength(0);
                grid.RowDefinitions.Add(rowdef);

                ColumnDefinition coldef = new ColumnDefinition();
                coldef.Width = new GridLength(0);
                grid.ColumnDefinitions.Add(coldef);
            }

            // ù°���� ���� ũ�⸦ 100���� �ʱ�ȭ ��Ų��
            grid.RowDefinitions[0].Height =
                        new GridLength(100, GridUnitType.Star);
            grid.ColumnDefinitions[0].Width =
                        new GridLength(100, GridUnitType.Star);

            // 2���� GridSplitter ��Ʈ����  Grid�� �߰� ��ĭ��    GridSplitter ��Ʈ���� Grid ����� �ڵ� ���� �� �� �ֵ���  ���ش�.
            GridSplitter split = new GridSplitter();
            split.HorizontalAlignment = HorizontalAlignment.Stretch;
            split.VerticalAlignment = VerticalAlignment.Center;
            split.Height = 6;
            grid.Children.Add(split);
            Grid.SetRow(split, 1);
            Grid.SetColumn(split, 0);
            Grid.SetColumnSpan(split, 3);

            split = new GridSplitter();
            split.HorizontalAlignment = HorizontalAlignment.Center;
            split.VerticalAlignment = VerticalAlignment.Stretch;
            split.Width = 6;
            grid.Children.Add(split);
            Grid.SetRow(split, 0);
            Grid.SetColumn(split, 1);
            Grid.SetRowSpan(split, 3);

            // XAML ��ü�� �����ֱ� ���� Frame �� �����Ѵ�
            frameParent = new Frame();
            frameParent.NavigationUIVisibility = NavigationUIVisibility.Hidden;
            grid.Children.Add(frameParent);

            // TextBox�� Grid�� ������
            txtbox.TextChanged += TextBoxOnTextChanged;
            grid.Children.Add(txtbox);

            // �ε�� ������ XamlCruncherSettings�� ����ȯ ��Ų��
            settingsXaml = (XamlCruncherSettings)settings;

            // Xaml�޴��� �ֻ��� �Ŵ��� ���� ��Ų��
            MenuItem itemXaml = new MenuItem();
            itemXaml.Header = "_Xaml";
            menu.Items.Insert(menu.Items.Count - 1, itemXaml);

            // XamlOrientationMenuItem�� �����ϰ� �Ŵ��� �߰� ��Ų��
            itemOrientation =
                new XamlOrientationMenuItem(grid, txtbox, frameParent);
            itemOrientation.Orientation = settingsXaml.Orientation;
            itemXaml.Items.Add(itemOrientation);

            //�ǿ� ������ �����ϱ� ���� �޴�
            MenuItem itemTabs = new MenuItem();
            itemTabs.Header = "_�ǰ��ݼ���...";
            itemTabs.Click += TabSpacesOnClick;
            itemXaml.Items.Add(itemTabs);

            //�Ľ� �ߴ��� �ϱ����� �޴�
            MenuItem itemNoParse = new MenuItem();
            itemNoParse.Header = "_Suspend Parsing";
            itemNoParse.IsCheckable = true;
            itemNoParse.SetBinding(MenuItem.IsCheckedProperty,
                                        "IsSuspendParsing");
            itemNoParse.DataContext = this;
            itemXaml.Items.Add(itemNoParse);

            // Reparse�ϱ� ���� Ŀ�ǵ�
            InputGestureCollection collGest = new InputGestureCollection();
            collGest.Add(new KeyGesture(Key.F6));
            RoutedUICommand commReparse =
                new RoutedUICommand("_Reparse", "Reparse",
                                    GetType(), collGest);

            // Reparse�� ���� �޴�
            MenuItem itemReparse = new MenuItem();
            itemReparse.Command = commReparse;
            itemXaml.Items.Add(itemReparse);

            // Reparse�� ���� Ŀ�ǵ� ���ε�
            CommandBindings.Add(new CommandBinding(commReparse,
                                ReparseOnExecuted));

            // â�� �����ֱ��� �� Ŀ�ǵ�
            collGest = new InputGestureCollection();
            collGest.Add(new KeyGesture(Key.F7));
            RoutedUICommand commShowWin =
                new RoutedUICommand("Show _Window", "ShowWindow",
                                    GetType(), collGest);

            // â�� �����ֱ� ���� �޴�
            MenuItem itemShowWin = new MenuItem();
            itemShowWin.Command = commShowWin;
            itemXaml.Items.Add(itemShowWin);

            //â�� �����ֱ� ���� Ŀ�ǵ� ���ε�
            CommandBindings.Add(new CommandBinding(commShowWin,
                            ShowWindowOnExecuted, ShowWindowCanExecute));

            // Save as Startup Document �޴�
            MenuItem itemTemplate = new MenuItem();
            itemTemplate.Header = "Save as Startup _Document";
            itemTemplate.Click += NewStartupOnClick;
            itemXaml.Items.Add(itemTemplate);

            // Help �޴� �� ������ ����
            MenuItem itemXamlHelp = new MenuItem();
            itemXamlHelp.Header = "_Help...";
            itemXamlHelp.Click += HelpOnClick;
            MenuItem itemHelp = (MenuItem)menu.Items[menu.Items.Count - 1];
            itemHelp.Items.Insert(0, itemXamlHelp);

            // ���ο� StatusBar(����ǥ����) �׸�
            statusParse = new StatusBarItem();
            status.Items.Insert(0, statusParse);
            status.Visibility = Visibility.Visible;

               //��Ÿ ���� ��Ȳ�鿡 ���� �ڵ鷯�� ����
            //�ڵ尡 ��ġ�� ���ο� Ư¡�̳� ��ȭ�� ǥ���Ѵ�
            Dispatcher.UnhandledException += DispatcherOnUnhandledException;
        }
        Window win; // Window created from XAML.

        #endregion Fields

        #region Constructors

        // Constructor.
        public XamlCruncher()
        {
            // New filter for File Open and Save dialog boxes.
            strFilter = "XAML Files(*.xaml)|*.xaml|All Files(*.*)|*.*";

            // Find the DockPanel and remove the TextBox from it.
            DockPanel dock = txtbox.Parent as DockPanel;
            dock.Children.Remove(txtbox);

            // Create a Grid with three rows and columns, all 0 pixels.
            Grid grid = new Grid();
            dock.Children.Add(grid);

            for (int i = 0; i < 3; i++)
            {
                RowDefinition rowdef = new RowDefinition();
                rowdef.Height = new GridLength(0);
                grid.RowDefinitions.Add(rowdef);

                ColumnDefinition coldef = new ColumnDefinition();
                coldef.Width = new GridLength(0);
                grid.ColumnDefinitions.Add(coldef);
            }

            // Initialize the first row and column to 100*.
            grid.RowDefinitions[0].Height =
                        new GridLength(100, GridUnitType.Star);
            grid.ColumnDefinitions[0].Width =
                        new GridLength(100, GridUnitType.Star);

            // Add two GridSplitter controls to the Grid.
            GridSplitter split = new GridSplitter();
            split.HorizontalAlignment = HorizontalAlignment.Stretch;
            split.VerticalAlignment = VerticalAlignment.Center;
            split.Height = 6;
            grid.Children.Add(split);
            Grid.SetRow(split, 1);
            Grid.SetColumn(split, 0);
            Grid.SetColumnSpan(split, 3);

            split = new GridSplitter();
            split.HorizontalAlignment = HorizontalAlignment.Center;
            split.VerticalAlignment = VerticalAlignment.Stretch;
            split.Width = 6;
            grid.Children.Add(split);
            Grid.SetRow(split, 0);
            Grid.SetColumn(split, 1);
            Grid.SetRowSpan(split, 3);

            // Create a Frame for displaying XAML object.
            frameParent = new Frame();
            frameParent.NavigationUIVisibility = NavigationUIVisibility.Hidden;
            grid.Children.Add(frameParent);

            // Put the TextBox in the Grid.
            txtbox.TextChanged += TextBoxOnTextChanged;
            grid.Children.Add(txtbox);

            // Case the loaded settings to XamlCruncherSettings.
            settingsXaml = (XamlCruncherSettings)settings;

            // Insert "Xaml" item on top-level menu.
            MenuItem itemXaml = new MenuItem();
            itemXaml.Header = "_Xaml";
            menu.Items.Insert(menu.Items.Count - 1, itemXaml);

            // Create XamlOrientationMenuItem & add to menu.
            itemOrientation =
                new XamlOrientationMenuItem(grid, txtbox, frameParent);
            itemOrientation.Orientation = settingsXaml.Orientation;
            itemXaml.Items.Add(itemOrientation);

            // Menu item to set tab spaces.
            MenuItem itemTabs = new MenuItem();
            itemTabs.Header = "_Tab Spaces...";
            itemTabs.Click += TabSpacesOnClick;
            itemXaml.Items.Add(itemTabs);

            // Menu item to suppress parsing.
            MenuItem itemNoParse = new MenuItem();
            itemNoParse.Header = "_Suspend Parsing";
            itemNoParse.IsCheckable = true;
            itemNoParse.SetBinding(MenuItem.IsCheckedProperty,
                                        "IsSuspendParsing");
            itemNoParse.DataContext = this;
            itemXaml.Items.Add(itemNoParse);

            // Command to reparse.
            InputGestureCollection collGest = new InputGestureCollection();
            collGest.Add(new KeyGesture(Key.F6));
            RoutedUICommand commReparse =
                new RoutedUICommand("_Reparse", "Reparse",
                                    GetType(), collGest);

            // Menu item to reparse.
            MenuItem itemReparse = new MenuItem();
            itemReparse.Command = commReparse;
            itemXaml.Items.Add(itemReparse);

            // Command binding to reparse.
            CommandBindings.Add(new CommandBinding(commReparse,
                                ReparseOnExecuted));

            // Command to show window.
            collGest = new InputGestureCollection();
            collGest.Add(new KeyGesture(Key.F7));
            RoutedUICommand commShowWin =
                new RoutedUICommand("Show _Window", "ShowWindow",
                                    GetType(), collGest);

            // Menu item to show window.
            MenuItem itemShowWin = new MenuItem();
            itemShowWin.Command = commShowWin;
            itemXaml.Items.Add(itemShowWin);

            // Command binding to show window.
            CommandBindings.Add(new CommandBinding(commShowWin,
                            ShowWindowOnExecuted, ShowWindowCanExecute));

            // Menu item to save as new startup document.
            MenuItem itemTemplate = new MenuItem();
            itemTemplate.Header = "Save as Startup _Document";
            itemTemplate.Click += NewStartupOnClick;
            itemXaml.Items.Add(itemTemplate);

            // Insert Help on Help menu.
            MenuItem itemXamlHelp = new MenuItem();
            itemXamlHelp.Header = "_Help...";
            itemXamlHelp.Click += HelpOnClick;
            MenuItem itemHelp = (MenuItem)menu.Items[menu.Items.Count - 1];
            itemHelp.Items.Insert(0, itemXamlHelp);

            // New StatusBar item.
            statusParse = new StatusBarItem();
            status.Items.Insert(0, statusParse);
            status.Visibility = Visibility.Visible;

            // Install handler for unhandled exception.
            // Comment out this code when experimenting with new features
            //   or changes to the program!
            Dispatcher.UnhandledException += DispatcherOnUnhandledException;
        }
示例#3
0
 // Override of LoadSettings loads XamlCruncherSettings.
 protected override object LoadSettings()
 {
     return(XamlCruncherSettings.Load(typeof(XamlCruncherSettings),
                                      strAppData));
 }
示例#4
0
        // Constructor.
        public XamlCruncher()
        {
            // New filter for File Open and Save dialog boxes.
            strFilter = "XAML Files(*.xaml)|*.xaml|All Files(*.*)|*.*";

            // Find the DockPanel and remove the TextBox from it.
            DockPanel dock = txtbox.Parent as DockPanel;

            dock.Children.Remove(txtbox);

            // Create a Grid with three rows and columns, all 0 pixels.
            Grid grid = new Grid();

            dock.Children.Add(grid);

            for (int i = 0; i < 3; i++)
            {
                RowDefinition rowdef = new RowDefinition();
                rowdef.Height = new GridLength(0);
                grid.RowDefinitions.Add(rowdef);

                ColumnDefinition coldef = new ColumnDefinition();
                coldef.Width = new GridLength(0);
                grid.ColumnDefinitions.Add(coldef);
            }

            // Initialize the first row and column to 100*.
            grid.RowDefinitions[0].Height =
                new GridLength(100, GridUnitType.Star);
            grid.ColumnDefinitions[0].Width =
                new GridLength(100, GridUnitType.Star);

            // Add two GridSplitter controls to the Grid.
            GridSplitter split = new GridSplitter();

            split.HorizontalAlignment = HorizontalAlignment.Stretch;
            split.VerticalAlignment   = VerticalAlignment.Center;
            split.Height = 6;
            grid.Children.Add(split);
            Grid.SetRow(split, 1);
            Grid.SetColumn(split, 0);
            Grid.SetColumnSpan(split, 3);

            split = new GridSplitter();
            split.HorizontalAlignment = HorizontalAlignment.Center;
            split.VerticalAlignment   = VerticalAlignment.Stretch;
            split.Width = 6;
            grid.Children.Add(split);
            Grid.SetRow(split, 0);
            Grid.SetColumn(split, 1);
            Grid.SetRowSpan(split, 3);

            // Create a Frame for displaying XAML object.
            frameParent = new Frame();
            frameParent.NavigationUIVisibility = NavigationUIVisibility.Hidden;
            grid.Children.Add(frameParent);

            // Put the TextBox in the Grid.
            txtbox.TextChanged += TextBoxOnTextChanged;
            grid.Children.Add(txtbox);

            // Case the loaded settings to XamlCruncherSettings.
            settingsXaml = (XamlCruncherSettings)settings;

            // Insert "Xaml" item on top-level menu.
            MenuItem itemXaml = new MenuItem();

            itemXaml.Header = "_Xaml";
            menu.Items.Insert(menu.Items.Count - 1, itemXaml);

            // Create XamlOrientationMenuItem & add to menu.
            itemOrientation =
                new XamlOrientationMenuItem(grid, txtbox, frameParent);
            itemOrientation.Orientation = settingsXaml.Orientation;
            itemXaml.Items.Add(itemOrientation);

            // Menu item to set tab spaces.
            MenuItem itemTabs = new MenuItem();

            itemTabs.Header = "_Tab Spaces...";
            itemTabs.Click += TabSpacesOnClick;
            itemXaml.Items.Add(itemTabs);

            // Menu item to suppress parsing.
            MenuItem itemNoParse = new MenuItem();

            itemNoParse.Header      = "_Suspend Parsing";
            itemNoParse.IsCheckable = true;
            itemNoParse.SetBinding(MenuItem.IsCheckedProperty,
                                   "IsSuspendParsing");
            itemNoParse.DataContext = this;
            itemXaml.Items.Add(itemNoParse);

            // Command to reparse.
            InputGestureCollection collGest = new InputGestureCollection();

            collGest.Add(new KeyGesture(Key.F6));
            RoutedUICommand commReparse =
                new RoutedUICommand("_Reparse", "Reparse",
                                    GetType(), collGest);

            // Menu item to reparse.
            MenuItem itemReparse = new MenuItem();

            itemReparse.Command = commReparse;
            itemXaml.Items.Add(itemReparse);

            // Command binding to reparse.
            CommandBindings.Add(new CommandBinding(commReparse,
                                                   ReparseOnExecuted));

            // Command to show window.
            collGest = new InputGestureCollection();
            collGest.Add(new KeyGesture(Key.F7));
            RoutedUICommand commShowWin =
                new RoutedUICommand("Show _Window", "ShowWindow",
                                    GetType(), collGest);

            // Menu item to show window.
            MenuItem itemShowWin = new MenuItem();

            itemShowWin.Command = commShowWin;
            itemXaml.Items.Add(itemShowWin);

            // Command binding to show window.
            CommandBindings.Add(new CommandBinding(commShowWin,
                                                   ShowWindowOnExecuted, ShowWindowCanExecute));

            // Menu item to save as new startup document.
            MenuItem itemTemplate = new MenuItem();

            itemTemplate.Header = "Save as Startup _Document";
            itemTemplate.Click += NewStartupOnClick;
            itemXaml.Items.Add(itemTemplate);

            // Insert Help on Help menu.
            MenuItem itemXamlHelp = new MenuItem();

            itemXamlHelp.Header = "_Help...";
            itemXamlHelp.Click += HelpOnClick;
            MenuItem itemHelp = (MenuItem)menu.Items[menu.Items.Count - 1];

            itemHelp.Items.Insert(0, itemXamlHelp);

            // New StatusBar item.
            statusParse = new StatusBarItem();
            status.Items.Insert(0, statusParse);
            status.Visibility = Visibility.Visible;

            // Install handler for unhandled exception.
            // Comment out this code when experimenting with new features
            //   or changes to the program!
            Dispatcher.UnhandledException += DispatcherOnUnhandledException;
        }
示例#5
0
        public XamlCruncher()
        {
            strFilter = "XAML files (*.xaml)|*.xaml|All files (*.*)|*.*";

            // find dockpanel and delete textbox inside it
            DockPanel dock = txtbox.Parent as DockPanel;

            dock.Children.Remove(txtbox);

            // create Grid panel 3x3
            Grid grid = new Grid();

            dock.Children.Add(grid);
            for (int i = 0; i < 3; i++)
            {
                RowDefinition rowdef = new RowDefinition()
                {
                    Height = new GridLength(0)
                };
                grid.RowDefinitions.Add(rowdef);

                ColumnDefinition coldef = new ColumnDefinition()
                {
                    Width = new GridLength(0)
                };
                grid.ColumnDefinitions.Add(coldef);
            }

            grid.RowDefinitions[0].Height   = new GridLength(100, GridUnitType.Star);
            grid.ColumnDefinitions[0].Width = new GridLength(100, GridUnitType.Star);

            // two splitters
            GridSplitter split = new GridSplitter()
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Center,
                Height = 6
            };

            grid.Children.Add(split);
            Grid.SetRow(split, 1);
            Grid.SetColumn(split, 0);
            Grid.SetColumnSpan(split, 3);

            split = new GridSplitter()
            {
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment   = VerticalAlignment.Stretch,
                Height = 6
            };
            grid.Children.Add(split);
            Grid.SetRow(split, 0);
            Grid.SetColumn(split, 1);
            Grid.SetColumnSpan(split, 3);

            // frame for showing XAML
            frameParent = new Frame()
            {
                NavigationUIVisibility = NavigationUIVisibility.Hidden
            };
            grid.Children.Add(frameParent);

            // textbox
            txtbox.TextChanged += TextboxOnTextChanged;
            grid.Children.Add(txtbox);

            // move settings to XamlCruncherSettings
            settingsXaml = (XamlCruncherSettings)settings;

            MenuItem itemXaml = new MenuItem()
            {
                Header = "_Xaml"
            };

            menu.Items.Insert(menu.Items.Count - 1, itemXaml);

            // create XamlOrientationMenuItem
            itemOrientation             = new XamlOrientationMenuItem(grid, txtbox, frameParent);
            itemOrientation.Orientation = settingsXaml.Orientation;
            itemXaml.Items.Add(itemOrientation);

            // menuItem for tabs
            MenuItem itemTabs = new MenuItem()
            {
                Header = "_Tab spaces..."
            };

            itemTabs.Click += TabSpacesOnClick;
            itemXaml.Items.Add(itemTabs);

            // menuItem for stopping parsing
            MenuItem itemNoParse = new MenuItem()
            {
                Header    = "_Suspend Parsing",
                IsChecked = true
            };

            itemNoParse.SetBinding(MenuItem.IsCheckedProperty, "IsSuspendParsing");
            itemNoParse.DataContext = this;
            itemXaml.Items.Add(itemNoParse);

            // command for continue parsing
            InputGestureCollection collGest = new InputGestureCollection();

            collGest.Add(new KeyGesture(Key.F6));
            RoutedUICommand commReparse = new RoutedUICommand(
                "_Reparse",
                "Reparse",
                GetType(),
                collGest);

            // menuItem for reparse
            MenuItem itemReparse = new MenuItem()
            {
                Command = commReparse
            };

            itemXaml.Items.Add(itemReparse);

            CommandBindings.Add(new CommandBinding(commReparse, ReparseOnExecuted));

            // command for show window
            collGest = new InputGestureCollection();
            collGest.Add(new KeyGesture(Key.F7));
            RoutedUICommand commShowWin = new RoutedUICommand(
                "Show _Window",
                "ShowWindow",
                GetType(),
                collGest);

            // menuItem for showing window
            MenuItem itemShowWin = new MenuItem()
            {
                Command = commShowWin
            };

            itemXaml.Items.Add(itemShowWin);
            CommandBindings.Add(new CommandBinding(
                                    commShowWin,
                                    ShowWindowOnExecuted,
                                    ShowWindowCanExecute));

            // menuItem for saving current content to a new document
            MenuItem itemTemplate = new MenuItem()
            {
                Header = "Save as Startup _Document"
            };

            itemTemplate.Click += NewStartupOnClick;
            itemXaml.Items.Add(itemTemplate);

            // help menuItem
            MenuItem itemXamlHelp = new MenuItem()
            {
                Header = "_Help..."
            };

            itemXamlHelp.Click += HelpOnClick;
            MenuItem itemHelp = (MenuItem)menu.Items[menu.Items.Count - 1];

            itemHelp.Items.Insert(0, itemXamlHelp);

            // new StatusBar
            statusParse = new StatusBarItem();
            status.Items.Insert(0, statusParse);
            status.Visibility = Visibility.Visible;

            // handler for exceptions. Comment this line when experimentating!
            Dispatcher.UnhandledException += DispatcherOnUnhandledException;
        }