예제 #1
0
        public MapcacheDialog(string text)
            : base("Mapcache", "cache.png", SizeToContent.Manual, ResizeMode.CanResize)
        {
            InitializeComponent();

            ShowInTaskbar         = true;
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner = WpfUtilities.TopWindow;

            _cache = new Mapcache();
            _cache.Commands.ModifiedStateChanged += _commands_ModifiedStateChanged;
            _asyncOperation = new AsyncOperation(_progressBar);

            ListViewDataTemplateHelper.GenerateListViewTemplateNew(_listView, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Name", DisplayExpression = "MapName", SearchGetAccessor = "MapName", ToolTipBinding = "MapName", TextWrapping = TextWrapping.Wrap, TextAlignment = TextAlignment.Center, FixedWidth = 140
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Width", DisplayExpression = "Xs", SearchGetAccessor = "Xs", ToolTipBinding = "Xs", TextAlignment = TextAlignment.Center, FixedWidth = 80
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Height", DisplayExpression = "Ys", SearchGetAccessor = "Ys", ToolTipBinding = "Ys", TextAlignment = TextAlignment.Center, FixedWidth = 80
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Size", DisplayExpression = "DisplaySize", SearchGetAccessor = "Len", ToolTipBinding = "DisplaySize", TextAlignment = TextAlignment.Center, FixedWidth = 150
                },
            }, new DefaultListViewComparer <MapInfo>(), new string[] { "Added", "{DynamicResource CellBrushAdded}" });

            _tmbUndo.SetUndo(_cache.Commands);
            _tmbRedo.SetRedo(_cache.Commands);
            _commands_ModifiedStateChanged(null, null);
            _listView.ItemsSource = _cache.ViewMaps;

            ApplicationShortcut.Link(ApplicationShortcut.Save, () => _menuItemSave_Click(null, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.Undo, () => _cache.Commands.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Redo, () => _cache.Commands.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.New, () => _menuItemNew_Click(null, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.Open, () => _menuItemOpenFrom_Click(null, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _miDelete_Click(null, null), this);

            _recentFilesManager              = new WpfRecentFiles(Configuration.ConfigAsker, 6, _menuItemRecentFiles, "Mapcache");
            _recentFilesManager.FileClicked += _recentFilesManager_FileClicked;

            if (text != null)
            {
                _recentFilesManager.AddRecentFile(text);
                _load(text);
            }
            else
            {
                // Open the latest file
                if (_recentFilesManager.Files.Count > 0 && File.Exists(_recentFilesManager.Files[0]))
                {
                    _load(_recentFilesManager.Files[0]);
                }
            }
        }
예제 #2
0
        private void _loadUi()
        {
            _rcm              = new WpfRecentFiles(SdeAppConfiguration.ConfigAsker, 6, _miLoadRecent, "Server database editor - IronPython recent files");
            _rcm.FileClicked += new RecentFilesManager.RFMFileClickedEventHandler(_rcm_FileClicked);

            Binder.Bind(_textEditor, () => SdeAppConfiguration.IronPythonScript);
            Binder.Bind(_miAutocomplete, () => SdeAppConfiguration.IronPythonAutocomplete);

            AvalonLoader.Load(_textEditor);
            AvalonLoader.SetSyntax(_textEditor, "Python");
            _textEditor.TextArea.TextEntered  += new TextCompositionEventHandler(_textArea_TextEntered);
            _textEditor.TextArea.TextEntering += new TextCompositionEventHandler(_textArea_TextEntering);

            this.PreviewKeyDown += new KeyEventHandler(_ironPythonDialog_PreviewKeyDown);

            _completionWindow            = new CompletionWindow(_textEditor.TextArea);
            _completionWindow.Background = Application.Current.Resources["TabItemBackground"] as Brush;
            _li = _completionWindow.CompletionList;
            ListView lv = _li.ListBox;

            lv.SelectionMode = SelectionMode.Single;
            lv.Background    = Application.Current.Resources["TabItemBackground"] as Brush;

            //Image
            ListViewDataTemplateHelper.GenerateListViewTemplateNew(lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "Image", TextAlignment = TextAlignment.Center, FixedWidth = 22, MaxHeight = 22, SearchGetAccessor = "Commands"
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Commands", DisplayExpression = "Text", TextAlignment = TextAlignment.Left, IsFill = true, ToolTipBinding = "Description"
                }
            }, null, new string[] { }, "generateHeader", "false");

            _completionWindow.Content  = null;
            _completionWindow          = null;
            _rowConsole.Height         = new GridLength(0);
            _buttonCloseConsole.Margin = new Thickness(0, 5, SystemParameters.HorizontalScrollBarButtonWidth + 2, 0);
            _textEditor.Drop          += new DragEventHandler(_textEditor_Drop);
        }