Example #1
0
 public frmScBrowser(string setting)
 {
     windowSetting = JsonConvert.DeserializeObject <WindowSetting>(setting);
     InitializeComponent();
     InitForm();
     InitSysList();
 }
Example #2
0
        static void Main(string[] args)
        {
            Rotor rL = new Rotor(FixedMechanicRotor.ROTOR_II);  //II has notch F
            Rotor rM = new Rotor(FixedMechanicRotor.ROTOR_IV);  //IV has notch K
            Rotor rR = new Rotor(FixedMechanicRotor.ROTOR_V);   //V  has notch A

            //Following WW2 Convention, it is Left-Mid-Right e.g. II IV V
            Rotor[] rotors = { rL, rM, rR };


            Reflector re   = new Reflector(FixedMechanicReflector.REFLECTOR_B);
            Plugboard plug = new Plugboard(new String[] {
                "AV", "BS", "CG", "DL", "FU", "HZ", "IN", "KM", "OW", "RX"
            });                                                                               //Barbarosa
            WindowSetting initialSetting = new WindowSetting('B', 'L', 'A');
            RingSetting   ringPositions  = new RingSetting(2, 21, 12);



            //an example of naming hassle because Enigma is both namespace and class
            Enigma.representation.Enigma enigma = new Enigma.representation.Enigma(rotors, re, plug, ringPositions, initialSetting);



            string myfile = "C:\\Users\\ToshiW\\Documents\\Visual Studio 2012\\Projects\\Enigma\\Enigma\\Resources\\BarbarosaCiphertext.txt";
            string input  = Utility.FileToString(myfile);
            //Console.WriteLine(readResult);
            //Console.ReadLine();

            //Let Enigma do its thing
            string result = enigma.encryptString(input);

            Console.WriteLine(result);
            Console.ReadLine();
        }
Example #3
0
        /// <summary>
        /// 创建窗体
        /// </summary>
        /// <param name="setting"></param>
        /// <returns></returns>
        public string CreateBrowserWindow(string setting)
        {
            if (string.IsNullOrEmpty(setting))
            {
                return("参数错误!");
            }
            string        result        = string.Empty;
            WindowSetting windowSetting = Global.GetWindowSetting(setting);

            setting = JsonConvert.SerializeObject(windowSetting);
            frmScBrowser newWindow = new frmScBrowser(setting);

            if (windowSetting.Modeless)
            {
                newWindow.LoadUrl(windowSetting.Url, windowSetting.Viewmodel);
                newWindow.Visible = false;
                if (newWindow.ShowDialog(this) == DialogResult.OK)
                {
                    result = newWindow.sReturnData;
                }
                newWindow.Dispose();
            }
            else
            {
                newWindow.LoadUrl(windowSetting.Url, windowSetting.Viewmodel);
                newWindow.Show();
                Global.formList.Add(newWindow);
            }
            return(result);
        }
        private static void SaveWindowSettings(Window window, List <WindowSetting> windowSettings)
        {
            if (window == null || windowSettings == null)
            {
                return;
            }

            var windowId = window.GetType().FullName;
            var setting  = windowSettings.FirstOrDefault(f => f.Id == windowId);

            if (setting == null)
            {
                setting = new WindowSetting {
                    Id = windowId
                };
                globalSettingsContainer.GeneralSettings.WindowSettings.Add(setting);
            }

            setting.Top         = window.Top;
            setting.Left        = window.Left;
            setting.Height      = window.Height;
            setting.Width       = window.Width;
            setting.WindowState = window.WindowState;
            globalSettingsContainer.Save();
        }
Example #5
0
 void OnEnable()
 {
     OnInit();
     editStats                = new AnimBool(false, Repaint);
     m_Tools                  = new ZuHeTool(OnChangeJianGe());
     mTittle                  = Tittle();
     mWindowSettings          = LearnWindowSetting.Instance;
     autoRepaintOnSceneChange = true;
     OnIsEasy();
 }
Example #6
0
        /// <summary>
        /// Restores the location of the specified windowsForm from the location information saved in the application configuration file.
        /// </summary>
        /// <param name="windowsForm">The Form whose location is to be restored.</param>
        /// <param name="settingsCategory">Settings category used to persist form location information</param>
        public static void RestoreLocation(this Form windowsForm, string settingsCategory)
        {
            CategorizedSettingsElementCollection settings = ConfigurationFile.Current.Settings[settingsCategory];

            if ((object)settings[windowsForm.Name] != null)
            {
                // Restore last saved window location
                WindowSetting locationSetting = new WindowSetting(settings[windowsForm.Name].Value);
                windowsForm.Left = locationSetting.ParamA(ScreenArea.LeftMostBound, ScreenArea.RightMostBound - windowsForm.MinimumSize.Width);
                windowsForm.Top  = locationSetting.ParamB(ScreenArea.TopMostBound, ScreenArea.BottomMostBound - windowsForm.MinimumSize.Height);
            }
        }
Example #7
0
        /// <summary>
        /// Restores the size of the specified windowsForm from the size information saved in the application configuration file.
        /// </summary>
        /// <param name="windowsForm">The Form whose size is to be restored.</param>
        /// <param name="settingsCategory">Settings category used to persist form size information</param>
        public static void RestoreSize(this Form windowsForm, string settingsCategory)
        {
            CategorizedSettingsElementCollection settings = ConfigurationFile.Current.Settings[settingsCategory];

            if ((object)settings[windowsForm.Name] != null)
            {
                // Restore last saved window size
                WindowSetting sizeSetting = new WindowSetting(settings[windowsForm.Name].Value);
                windowsForm.Width  = sizeSetting.ParamA(windowsForm.MinimumSize.Width, ScreenArea.MaximumWidth);
                windowsForm.Height = sizeSetting.ParamB(windowsForm.MinimumSize.Height, ScreenArea.MaximumHeight);
            }
        }
Example #8
0
        /**
         * Get the appropriate offset (always > 0) of the internal rotor core
         * with respect to global 'A' position
         * This offset is influenced by
         *  i) the ring setting (which stays the same for a given ciphertext, and
         *  ii) the window value (which updates every time the enigma ticks)
         * @param ringSetting
         * @param windowSetting
         * @param slot
         * @return
         */

        public static int GetOffsetRotorInternal(RingSetting ringSetting, WindowSetting windowSetting, int slot)
        {
            //for easy intuition, we call the global 'A' position the sea level

            int dispRingAboveSea;               //displacement of Ring with respect to global 'A' position
            int dispRotorInternalWrtRing;
            int dispRotorInternalAboveSea;      //always > 0, expressed in mod26


            dispRingAboveSea          = 'A' - windowSetting.getWindowValue(slot); //if window shows 'C', disp = -2
            dispRotorInternalWrtRing  = ringSetting.ringOffset(slot);             //offset = 4 means internal A is locked to ring's E
            dispRotorInternalAboveSea = (dispRingAboveSea + dispRotorInternalWrtRing + 26) % 26;

            return(dispRotorInternalAboveSea);
        }
Example #9
0
    void Awake()
    {
        instance = this;

        _hwnd = FindWindow(null, UnityEngine.Application.productName);
        UnityDragAndDropHook.InstallHook(_hwnd);
        UnityDragAndDropHook.OnDroppedFiles += OpenDragFile;

        if (UnityEngine.Application.isEditor)
        {
            return;
        }


        //  UnityEngine.Screen.fullScreen = false;

        //SetWindowLong(_hwnd, GWL_EXSTYLE, WS_EX_LAYERED);
        //int intExTemp = GetWindowLong(_hwnd, GWL_EXSTYLE);

        //SetWindowLong(_hwnd, GWL_STYLE, WS_POPUP | WS_VISIBLE);
        //SetWindowLong(_hwnd, GWL_EXSTYLE, WS_EX_LAYERED | WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT);


        SetWindowLong(_hwnd, GWL_EXSTYLE, WS_EX_LAYERED);
        int intExTemp = GetWindowLong(_hwnd, GWL_EXSTYLE);

        SetWindowLong(_hwnd, GWL_EXSTYLE, intExTemp | WS_EX_TRANSPARENT | WS_EX_LAYERED);

        SetWindowLong(_hwnd, GWL_STYLE, GetWindowLong(_hwnd, GWL_STYLE) & ~WS_BORDER & ~WS_CAPTION);

        int currentX = UnityEngine.Screen.currentResolution.width / 2 - winWidth / 2;
        int currentY = UnityEngine.Screen.currentResolution.height / 2 - winHeight / 2;

        SetWindowPos(_hwnd, (int)currentTopType, currentX, currentY, winWidth, winHeight, SWP_SHOWWINDOW);

        var margins = new MARGINS()
        {
            cxLeftWidth = -1
        };

        DwmExtendFrameIntoClientArea(_hwnd, ref margins);
    }
Example #10
0
        public static WindowSetting GetWindowSetting(string setting)
        {
            WindowSetting inWindowSetting  = JsonConvert.DeserializeObject <WindowSetting>(setting);
            WindowSetting newWindowSetting = Global.sysConfig.WindowConfig;

            newWindowSetting.Title        = string.IsNullOrEmpty(inWindowSetting.Title) ? newWindowSetting.Title : inWindowSetting.Title;
            newWindowSetting.Fixtitle     = inWindowSetting.Fixtitle;
            newWindowSetting.Width        = inWindowSetting.Width == null ? newWindowSetting.Width : inWindowSetting.Width;
            newWindowSetting.Height       = inWindowSetting.Height == null ? newWindowSetting.Height : inWindowSetting.Height;
            newWindowSetting.Modeless     = inWindowSetting.Modeless;
            newWindowSetting.Url          = ConfigureHelper.getWebUrl(inWindowSetting.Url, "");;
            newWindowSetting.Viewmodel    = string.IsNullOrEmpty(inWindowSetting.Viewmodel) ? newWindowSetting.Viewmodel : inWindowSetting.Viewmodel;
            newWindowSetting.Fullscreen   = inWindowSetting.Fullscreen;
            newWindowSetting.Statusbar    = inWindowSetting.Statusbar;
            newWindowSetting.Resizable    = inWindowSetting.Resizable;
            newWindowSetting.Maximize     = inWindowSetting.Maximize;
            newWindowSetting.Minimize     = inWindowSetting.Minimize;
            newWindowSetting.EscKeyEnable = inWindowSetting.EscKeyEnable;
            return(newWindowSetting);
        }
Example #11
0
        public void LoadSettings()
        {
            if (Type == WindowType.None || !CEnvir.Loaded)
            {
                return;
            }

            Settings = CEnvir.WindowSettings.Binding.FirstOrDefault(x => x.Resolution == Config.GameSize && x.Window == Type);

            if (Settings != null)
            {
                ApplySettings();
                return;
            }

            Settings            = CEnvir.WindowSettings.CreateNewObject();
            Settings.Resolution = Config.GameSize;
            Settings.Window     = Type;
            Settings.Size       = Size;
            Settings.Visible    = Visible;
            Settings.Location   = Location;
        }
Example #12
0
        /// <summary>
        /// Restores the location of the specified windowsForm from the location information saved in the application configuration file.
        /// </summary>
        /// <param name="windowsForm">The Form whose location is to be restored.</param>
        /// <param name="settingsCategory">Settings category used to persist form location information</param>
        public static void RestoreLocation(this Form windowsForm, string settingsCategory)
        {
            CategorizedSettingsElementCollection settings = ConfigurationFile.Current.Settings[settingsCategory];

            if ((object)settings[windowsForm.Name] != null)
            {
                // Restore last saved window location
                WindowSetting locationSetting = new WindowSetting(settings[windowsForm.Name].Value);
                windowsForm.Left = locationSetting.ParamA(ScreenArea.LeftMostBound, ScreenArea.RightMostBound - windowsForm.MinimumSize.Width);
                windowsForm.Top = locationSetting.ParamB(ScreenArea.TopMostBound, ScreenArea.BottomMostBound - windowsForm.MinimumSize.Height);
            }
        }
Example #13
0
        /// <summary>
        /// Restores the size of the specified windowsForm from the size information saved in the application configuration file.
        /// </summary>
        /// <param name="windowsForm">The Form whose size is to be restored.</param>
        /// <param name="settingsCategory">Settings category used to persist form size information</param>
        public static void RestoreSize(this Form windowsForm, string settingsCategory)
        {
            CategorizedSettingsElementCollection settings = ConfigurationFile.Current.Settings[settingsCategory];

            if ((object)settings[windowsForm.Name] != null)
            {
                // Restore last saved window size
                WindowSetting sizeSetting = new WindowSetting(settings[windowsForm.Name].Value);
                windowsForm.Width = sizeSetting.ParamA(windowsForm.MinimumSize.Width, ScreenArea.MaximumWidth);
                windowsForm.Height = sizeSetting.ParamB(windowsForm.MinimumSize.Height, ScreenArea.MaximumHeight);
            }
        }
 public WindowSettingViewModel(string key)
 {
     Setting = SettingsHost.Cache <WindowSetting>(k => new WindowSetting(key), key);
 }
Example #15
0
        /// <summary>
        /// 获取系统初始化时的系统配置
        /// </summary>
        /// <returns></returns>
        public static Configure getInitConfigure()
        {
            Configure     conf        = new Configure();
            string        sectionName = "window";
            string        file        = System.AppDomain.CurrentDomain.BaseDirectory + "application.ini";
            IniFileHelper ini         = new IniFileHelper(file);

            conf.Main = ini.IniReadValue(sectionName, "main", "about:blank");

            try
            {
                #region 默认窗体配配置
                WindowSetting windowConf = new WindowSetting();
                windowConf.Title           = ini.IniReadValue(sectionName, "title", "杭州圣辰网络科技有限公司");
                windowConf.Fixtitle        = bool.Parse(ini.IniReadValue(sectionName, "fixtitle", "false"));
                windowConf.Width           = int.Parse(ini.IniReadValue(sectionName, "width", "1024"));
                windowConf.Height          = int.Parse(ini.IniReadValue(sectionName, "height", "768"));
                windowConf.Toolbar         = bool.Parse(ini.IniReadValue(sectionName, "toolbar", "true"));
                windowConf.Statusbar       = bool.Parse(ini.IniReadValue(sectionName, "statusbar", "true"));
                windowConf.Resizable       = bool.Parse(ini.IniReadValue(sectionName, "resizable", "true"));
                windowConf.Fullscreen      = bool.Parse(ini.IniReadValue(sectionName, "fullscreen", "false"));
                windowConf.Show_in_taskbar = bool.Parse(ini.IniReadValue(sectionName, "show_in_taskbar", "true"));
                windowConf.Frame           = bool.Parse(ini.IniReadValue(sectionName, "frame", "true"));
                windowConf.Position        = ini.IniReadValue(sectionName, "position", "center");

                string min_width = ini.IniReadValue(sectionName, "min_width");
                if (!string.IsNullOrEmpty(min_width))
                {
                    windowConf.Min_width = int.Parse(min_width);
                }
                string min_height = ini.IniReadValue(sectionName, "min_height");
                if (!string.IsNullOrEmpty(min_height))
                {
                    windowConf.Min_height = int.Parse(min_height);
                }
                string max_width = ini.IniReadValue(sectionName, "max_width");
                if (!string.IsNullOrEmpty(max_width))
                {
                    windowConf.Max_width = int.Parse(max_width);
                }
                string max_height = ini.IniReadValue(sectionName, "max_height");
                if (!string.IsNullOrEmpty(max_height))
                {
                    windowConf.Max_height = int.Parse(max_height);
                }
                windowConf.Show      = bool.Parse(ini.IniReadValue(sectionName, "show", "true"));
                windowConf.Kiosk     = bool.Parse(ini.IniReadValue(sectionName, "kiosk", "false"));
                windowConf.Showerror = bool.Parse(ini.IniReadValue(sectionName, "showerror", "false"));

                conf.WindowConfig = windowConf;
                #endregion

                conf.Defaultsys       = ini.IniReadValue("scwebapp", "defaultmain", "0");
                conf.DefaultViewModel = ini.IniReadValue("scwebapp", "defaultviewmodel", Enum.GetName(typeof(ScWebBrowser.Constants.Browser_渲染模式), ScWebBrowser.Constants.Browser_渲染模式.IE7));
                int count  = int.Parse(ini.IniReadValue("webapp", "webcount", "5"));//默认5个系统
                int gIndex = 1;
                while (gIndex <= count)
                {
                    ScSystem si = null;
                    if (gIndex <= 5)
                    {
                        si = ScSystem.GetScSystem(ini.IniReadValue("webapp", "weburl" + gIndex, getDfltUrl(gIndex.ToString())));
                    }
                    else
                    {
                        si = ScSystem.GetScSystem(ini.IniReadValue("webapp", "weburl" + gIndex, ""));
                    }
                    if (si != null)
                    {
                        if (si.Deflt == "Y")
                        {
                            conf.MainUrl          = ConfigureHelper.getWebUrl(conf.Main, si.Url);
                            conf.DefaultViewModel = si.Viewmodel;
                        }
                        conf.SysList.Add(si);
                    }
                    gIndex++;
                }
                //如果系统没有默认访问的his系统,则访问首页
                conf.MainUrl = string.IsNullOrEmpty(conf.MainUrl) ?  getWebUrl(conf.Main, "") : conf.MainUrl;
                return(conf);
            }catch (Exception ex) {
                MessageBox.Show("解析配置文件失败!" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(conf);
            }
        }