Skip to content

Instantly share code, notes, and snippets.

@masoo
Created December 19, 2013 04:47
Show Gist options
  • Save masoo/8034557 to your computer and use it in GitHub Desktop.
Save masoo/8034557 to your computer and use it in GitHub Desktop.
masoojer の画面を最大化にする。
# -*- coding: utf-8 -*-
require 'mscorlib'
require 'System'
require 'PresentationFramework'
module Masoojer
def self.full_screen
if @full_screen_toggle then
self.full_screen_off
else
self.full_screen_on
end
end
def self.full_screen_on
@window = $mainWindow
@before_border_thickness = @window.FindName("EditorComponent").BorderThickness
@before_border_brush = @window.FindName("EditorComponent").BorderBrush
@before_window_style = @window.WindowStyle
@before_window_state = @window.WindowState
@before_topmost = @window.Topmost
editor_component = @window.FindName("EditorComponent")
editor_component.BorderThickness = System::Windows::Thickness.new(20)
editor_component.BorderBrush = System::Windows::Media::SolidColorBrush.new(System::Windows::SystemColors.MenuBarColor)
@window.WindowStyle = System::Windows::WindowStyle.None
@window.WindowState = System::Windows::WindowState.Maximized
@window.Topmost = true
@full_screen_toggle = true
end
def self.full_screen_off
editor_component = @window.FindName("EditorComponent")
editor_component.BorderThickness = @before_border_thickness
editor_component.BorderBrush = @before_border_brush
@window.WindowStyle = @before_window_style
@window.WindowState = @before_window_state
@window.Topmost = @before_topmost
@full_screen_toggle = false
end
end
menu_fullscreen = System::Windows::Controls::MenuItem.new()
menu_fullscreen.Name = System::String.new("MenuItemFullScreen")
menu_fullscreen.Header = System::String.new("最大化モードon/off")
$menu.FindName("MenuItemTools").Items.Add(menu_fullscreen)
$menu.RegisterName("MenuItemFullScreen", menu_fullscreen)
$menu.FindName("MenuItemFullScreen").Click do |s, e|
Masoojer::full_screen
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment