public void palettedel() { if (myPaletteSet != null) { myPaletteSet.Close(); } }
private static void ShowMenuByID(string productID) { if (menuPalette.Visible) { menuPalette.Close(); menuPalette.Dispose(); } Product product = ProductManager.GetProductRecordByID(productID); string title = ProductManager.GetProductTitle(); menuWindow.Close(); menuWindow = product.GetProductMenuWindow(); Application.MainWindow.Text = title; menuPalette = new PaletteSet(title); System.Windows.Controls.ScrollViewer root = menuWindow.Content as System.Windows.Controls.ScrollViewer; root.Width = 240; root.Height = 2000; root.Margin = new System.Windows.Thickness(0); menuPalette.AddVisual("菜单", root); menuPalette.Size = new System.Drawing.Size(200, 640); menuPalette.MinimumSize = new System.Drawing.Size(200, 640); menuPalette.SizeChanged += (sender, e) => root.Width = menuPalette.Size.Width; menuPalette.Visible = true; menuPalette.Dock = DockSides.Right; menuPalette.DockEnabled = DockSides.Right; }
// Helper function to show a palette internal static PaletteSet ShowPalette( PaletteSet ps, Guid guid, string cmd, string title, Uri uri, bool reload = false ) { // If the reload flag is true we'll force an unload/reload // (this isn't strictly needed - given our refresh function - // but I've left it in for possible future use) if (reload && ps != null) { // Close the palette and make sure we process windows // messages, otherwise sizing is a problem ps.Close(); System.Windows.Forms.Application.DoEvents(); ps.Dispose(); ps = null; } if (ps == null) { ps = new PaletteSet(cmd, guid); } else { if (ps.Visible) { return(ps); } } if (ps.Count != 0) { ps.Remove(0); } ps.Add(title, uri); ps.Visible = true; return(ps); }