Exemplo n.º 1
0
 public void toolStripMenuItem_Reboot_Click(object sender, EventArgs e)
 {
     OpeInfoTable.GetInstance().UnregisterAllOpeToHotKey(Window.GetHWnd());
     //OpeScript.GetInstance().CloseLua();
     System.Diagnostics.Process.Start(Application.ResourceAssembly.Location);
     Application.Current.Shutdown();
 }
Exemplo n.º 2
0
 private static void SaveDataTableToXML(OpeInfoTable dt, string xmlPath)
 {
     using (FileStream fs
                = new FileStream(xmlPath, FileMode.Create, FileAccess.Write, FileShare.ReadWrite))
     {
         XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(dt.GetType());
         serializer.Serialize(fs, dt);
     }
 }
Exemplo n.º 3
0
        public MainSettingWindow()
        {
            InitializeComponent();


            dgOpeList.DataContext = OpeInfoTable.GetInstance();

            _LLKeyboardProc = new KeyboardHook.LowLevelKeyboardProc(LLKeyboardProc);
            hHandle         = KeyboardHook.SetHook(_LLKeyboardProc);
        }
Exemplo n.º 4
0
        private void CloseWithOK()
        {
            UnregisterHotkeys();

            OpeInfoTable.GetInstance().Save();

            OpeScript.GetInstance().Initialize();

            MyHide();
        }
Exemplo n.º 5
0
        private void btnEditScript_Click(object sender, RoutedEventArgs e)
        {
            DataGridRow curt_row = VisualTreeUtil.FindParent <DataGridRow>(sender as DependencyObject);

            int idx = int.Parse((dgOpeList.Columns[0].GetCellContent(curt_row) as TextBlock).Text);

            ScriptSettingWindow script_setting_window
                = new ScriptSettingWindow(OpeInfoTable.GetInstance().GetRowById(idx));

            script_setting_window.Owner = this;
            script_setting_window.ShowDialog();
        }
Exemplo n.º 6
0
        private static void addRuntimeData(ref OpeInfoTable table)
        {
            if (table.Columns.Contains("Enabled") == false)
            {
                table.Columns.Add("Enabled", typeof(bool));
                table.Columns["Enabled"].DefaultValue = true;

                foreach (DataRow row in table.Rows)
                {
                    row["Enabled"] = true;
                }
            }
        }
Exemplo n.º 7
0
        private void CloseWithCancel()
        {
            UnregisterHotkeys();

            OpeInfoTable.GetInstance().RollBackBeforeEditing();

            // Update reference.
            dgOpeList.DataContext = OpeInfoTable.GetInstance();
            dgOpeList.Items.Refresh();

            OpeScript.GetInstance().Initialize();

            MyHide();
        }
Exemplo n.º 8
0
        private void StopSimulation()
        {
            grdDebugSet.Visibility = Visibility.Hidden;
            GridLengthConverter gridLengthConverter = new GridLengthConverter();

            RDefSim.Height = (GridLength)gridLengthConverter.ConvertFrom("0");
            MakeEnableDgOpeList();

            OpeScript.GetInstance().Initialize();

            OpeInfoTable.GetInstance().UnregisterAllOpeToHotKey(GetHWnd());

            btnSimulation.IsChecked = false;
        }
Exemplo n.º 9
0
        private void StartSimulation()
        {
            MakeDisenableDgOpeList();
            RowDefinition       row_def             = new RowDefinition();
            GridLengthConverter gridLengthConverter = new GridLengthConverter();

            RDefSim.Height         = (GridLength)gridLengthConverter.ConvertFrom("1*");
            grdDebugSet.Visibility = Visibility.Visible;

            OpeScript.GetInstance().Initialize(TbxOutput);

            OpeInfoTable.GetInstance().RegisterAllOpeToHotKey(GetHWnd());

            btnSimulation.IsChecked = true;
        }
Exemplo n.º 10
0
 private static void LoadDataTableFromXML(ref OpeInfoTable dt, string xmlPath)
 {
     try
     {
         using (FileStream fs = new FileStream(xmlPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
         {
             XmlSerializer serializer = new XmlSerializer(typeof(OpeInfoTable));
             dt = (OpeInfoTable)serializer.Deserialize(fs);
         }
     }
     catch (Exception e)
     {
         dt = null;
         return;
     }
 }
Exemplo n.º 11
0
        private static OpeInfoTable Load()
        {
            OpeInfoTable table = null;

            LoadDataTableFromXML(ref table, SETTING_FILE_NAME);

            if (table != null)
            {
                addRuntimeData(ref table);
                return(table);
            }
            else
            {
                return(new OpeInfoTable(true));
            }
        }
Exemplo n.º 12
0
        public static int GetNextHighestPriority()
        {
            int max_priority = 0;

            foreach (DataRow r in OpeInfoTable.GetInstance().Rows)
            {
                if (r["HotKeyObject"] is ComboKey)
                {
                    int tmp = ((ComboKey)r["HotKeyObject"]).Priority;

                    if (tmp > max_priority)
                    {
                        max_priority = tmp;
                    }
                }
            }

            return(max_priority + 1);
        }
Exemplo n.º 13
0
        private void ThreadPreprocessMessageMethod(ref MSG msg, ref bool handled)
        {
            const int WM_HOTKEY = 0x0312;

            switch (msg.message)
            {
            case WM_HOTKEY:
                int id = msg.wParam.ToInt32();
                int combo_id;
                if (ComboKey.FindComboToFire(id, out combo_id))
                {
                    OpeInfoTable.GetInstance().DoOpeScript(combo_id);
                }
                else
                {
                    OpeInfoTable.GetInstance().DoOpeScript(id);
                }
                handled = true;
                break;
            }
        }
Exemplo n.º 14
0
        private void dgOpeList_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (dgOpeList.CurrentColumn.Header.ToString() != "HotKey")
            {
                return;
            }

            ModifierKeys modifierKeys = Keyboard.Modifiers;

            DataRowView selected_item = (DataRowView)dgOpeList.SelectedItem;

            if (isBeingPressedWinKey)
            {
                modifierKeys |= ModifierKeys.Windows;
            }

            if (HotKey.CanSet(e, modifierKeys))
            {
                OpeInfoTable.SetHotkey(e, modifierKeys, selected_item.Row);
                e.Handled = true;
            }
            else
            {
                if (HotKey.IsClearKey(e))
                {
                    OpeInfoTable.ClearHotKey(selected_item.Row);
                }

                if (modifierKeys == ModifierKeys.None && e.Key == Key.F2)
                {
                    e.Handled = false;
                    return;
                }

                e.Handled = false;
            }
        }
Exemplo n.º 15
0
        private void dgOpeList_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
        {
            if (e.Column.Header.ToString() != "HotKey")
            {
                return;
            }

            if (e.EditAction == DataGridEditAction.Cancel)
            {
                return;
            }

            if (e.EditingElement is TextBox)
            {
                if (OpeInfoTable.SetComboKey(((TextBox)e.EditingElement).Text, ((DataRowView)e.Row.DataContext).Row))
                {
                    e.Cancel = false;
                }
                else
                {
                    e.Cancel = true;
                }
            }
        }
Exemplo n.º 16
0
 public void toolStripMenuItem_Exit_Click(object sender, EventArgs e)
 {
     OpeInfoTable.GetInstance().UnregisterAllOpeToHotKey(Window.GetHWnd());
     //OpeScript.GetInstance().CloseLua();
     Application.Current.Shutdown();
 }
Exemplo n.º 17
0
 private void UnregisterHotkeys()
 {
     OpeInfoTable.GetInstance().UnregisterAllOpeToHotKey(GetHWnd());
 }
Exemplo n.º 18
0
 private void OpenSetting()
 {
     OpeInfoTable.GetInstance().UnregisterAllOpeToHotKey(Window.GetHWnd());
     Window.MyShow();
 }
Exemplo n.º 19
0
 private void btnAdd_Click(object sender, RoutedEventArgs e)
 {
     OpeInfoTable.GetInstance().AddRowAsDefault();
 }