public void LoadIcons() { Type ourType = this.GetType(); FieldInfo[] fields = ourType.GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly); foreach (FieldInfo fi in fields) { if (fi.FieldType.IsSubclassOf(typeof(PdnMenuItem)) || fi.FieldType == typeof(PdnMenuItem)) { string iconFileName = "Icons." + fi.Name[0].ToString().ToUpper() + fi.Name.Substring(1) + "Icon.png"; PdnMenuItem mi = (PdnMenuItem)fi.GetValue(this); Stream iconStream = PdnResources.GetResourceStream(iconFileName); if (iconStream != null) { iconStream.Dispose(); mi.SetIcon(iconFileName); } else { Tracing.Ping(iconFileName + " not found"); } } } this.iconsLoaded = true; }
public AboutDialog() { // // Required for Windows Form Designer support // InitializeComponent(); this.richCreditsBox.BackColor = SystemColors.Window; string textFormat = PdnResources.GetString("AboutDialog.Text.Format"); this.Text = string.Format(textFormat, PdnInfo.GetBareProductName()); this.pdnBanner.BannerText = string.Empty;// PdnInfo.GetFriendlyVersionString(); this.richCreditsBox.LoadFile(PdnResources.GetResourceStream("Files.AboutCredits.rtf"), RichTextBoxStreamType.RichText); this.copyrightLabel.Text = PdnInfo.GetCopyrightString(); this.Icon = PdnInfo.AppIcon; this.okButton.Text = PdnResources.GetString("Form.OkButton.Text"); this.okButton.Location = new Point((this.ClientSize.Width - this.okButton.Width) / 2, this.okButton.Top); this.creditsLabel.Text = PdnResources.GetString("AboutDialog.CreditsLabel.Text"); Font bannerFont = this.pdnBanner.BannerFont; Font newBannerFont = Utility.CreateFont(bannerFont.Name, 8.0f, bannerFont.Style); this.pdnBanner.BannerFont = newBannerFont; newBannerFont.Dispose(); bannerFont.Dispose(); this.versionLabel.Text = PdnInfo.GetFullAppName(); }
private void Activate() { Debug.Assert(this.active != true, "already active!"); this.active = true; this.handCursor = new Cursor(PdnResources.GetResourceStream("Cursors.PanToolCursor.cur")); this.handCursorMouseDown = new Cursor(PdnResources.GetResourceStream("Cursors.PanToolCursorMouseDown.cur")); this.handCursorInvalid = new Cursor(PdnResources.GetResourceStream("Cursors.PanToolCursorInvalid.cur")); this.panTracking = false; this.panMode = false; this.mouseDown = 0; this.savedTiles = null; this.saveRegion = null; this.scratchSurface = DocumentWorkspace.BorrowScratchSurface(this.GetType().Name + ": Tool.Activate()"); #if DEBUG this.haveClearedScratch = false; #endif Selection.Changing += new EventHandler(SelectionChangingHandler); Selection.Changed += new EventHandler(SelectionChangedHandler); HistoryStack.ExecutingHistoryMemento += new ExecutingHistoryMementoEventHandler(ExecutingHistoryMemento); HistoryStack.ExecutedHistoryMemento += new ExecutedHistoryMementoEventHandler(ExecutedHistoryMemento); HistoryStack.FinishedStepGroup += new EventHandler(FinishedHistoryStepGroup); this.trackingNub = new MoveNubRenderer(this.RendererList); this.trackingNub.Visible = false; this.trackingNub.Size = new SizeF(10, 10); this.trackingNub.Shape = MoveNubShape.Compass; this.RendererList.Add(this.trackingNub, false); OnActivate(); }
protected override void OnDragDrop(DragEventArgs drgevent) { Activate(); if (!IsCurrentModalForm || !Enabled) { // do nothing } else if (drgevent.Data.GetDataPresent(DataFormats.FileDrop)) { string[] allFiles = (string[])drgevent.Data.GetData(DataFormats.FileDrop); if (allFiles == null) { return; } string[] files = PruneDirectories(allFiles); bool importAsLayers = true; if (files.Length == 0) { return; } else { TaskButton openTB = new TaskButton( ImageResource.Get("Icons.MenuFileOpenIcon.png").Reference, PdnResources.GetString("DragDrop.OpenOrImport.OpenButton.ActionText"), PdnResources.GetString("DragDrop.OpenOrImport.OpenButton.ExplanationText")); string importLayersExplanation; if (this.appWorkspace.DocumentWorkspaces.Length == 0) { importLayersExplanation = PdnResources.GetString("DragDrop.OpenOrImport.ImportLayers.ExplanationText.NoImagesYet"); } else { importLayersExplanation = PdnResources.GetString("DragDrop.OpenOrImport.ImportLayers.ExplanationText"); } TaskButton importLayersTB = new TaskButton( ImageResource.Get("Icons.MenuLayersImportFromFileIcon.png").Reference, PdnResources.GetString("DragDrop.OpenOrImport.ImportLayers.ActionText"), importLayersExplanation); TaskButton clickedTB = TaskDialog.Show( this, new Icon(PdnResources.GetResourceStream("Icons.Question.ico")), PdnInfo.GetBareProductName(), null, false, PdnResources.GetString("DragDrop.OpenOrImport.InfoText"), new TaskButton[] { openTB, importLayersTB, TaskButton.Cancel }, null, TaskButton.Cancel); if (clickedTB == openTB) { importAsLayers = false; } else if (clickedTB == importLayersTB) { importAsLayers = true; } else { return; } } if (!importAsLayers) { // open files into new tabs this.appWorkspace.OpenFilesInNewWorkspace(files); } else { // no image open? we will have to create one if (this.appWorkspace.ActiveDocumentWorkspace == null) { Size newSize = this.appWorkspace.GetNewDocumentSize(); this.appWorkspace.CreateBlankDocumentInNewWorkspace( newSize, Document.DefaultDpuUnit, Document.GetDefaultDpu(Document.DefaultDpuUnit), false); } ImportFromFileAction action = new ImportFromFileAction(); HistoryMemento ha = action.ImportMultipleFiles(this.appWorkspace.ActiveDocumentWorkspace, files); if (ha != null) { this.appWorkspace.ActiveDocumentWorkspace.History.PushNewMemento(ha); } } } base.OnDragDrop(drgevent); }