Example #1
0
        public static void test01()
        {
            //initialize the form
            var _form = new Form();

            Color _color = Color.Black;

            _form.FormBorderStyle = FormBorderStyle.None;
            _form.ShowInTaskbar   = false;
            _form.TopMost         = true;
            _form.Visible         = false;
            _form.Left            = 0;
            _form.Top             = 0;
            _form.Width           = 1;
            _form.Height          = 1;
            _form.Hide();
            _form.Show();
            _form.Opacity = 0.1;

            //set popup style
            int num1 = Win32Util.GetWindowLong(_form.Handle, -20);

            Win32Util.SetWindowLong(_form.Handle, -20, num1 | 0x80);
            Win32Util.ShowWindow(_form.Handle, 8);
            Win32Util.SetWindowPos(_form.Handle, Win32Util.HWND_TOPMOST, TLX_, TLY_, width_, height_, 0x10);
        }
Example #2
0
        private void executeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(_packageFilePath))
            {
                Win32Util.ShowError(this, "Откройте сначала пакет, чтобы его выполнить");
                return;
            }
            try
            {
                string workPath          = GetRootPath();
                string installerFullPath = Path.Combine(workPath, "Gin.Installer.exe");

                Process process = new Process();
                process.StartInfo.FileName               = installerFullPath;
                process.StartInfo.Arguments              = @"""" + _packageFilePath + @"""";
                process.StartInfo.CreateNoWindow         = true;
                process.StartInfo.WindowStyle            = ProcessWindowStyle.Hidden;
                process.StartInfo.RedirectStandardOutput = true;
                process.StartInfo.UseShellExecute        = false;
                process.StartInfo.ErrorDialog            = true;
                process.Start();
            }
            catch (Exception ex)
            {
                Win32Util.ShowError(this, "Не удалось запустить инсталлятор. Описание ошибки приведено далее. \r\n" + ex.Message + "\r\n" + ex.StackTrace);
            }
        }
Example #3
0
 static void Main(string[] Arguments)
 {
     if (mutex.WaitOne(TimeSpan.Zero, true))
     {
         AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
         PluginManager = new PluginManager();
         FileManager   = new FileManager();
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         if (Arguments.Length > 0)
         {
             Application.Run(new Form1(Arguments[0]));
         }
         else
         {
             Application.Run(new Form1());
         }
     }
     else
     {
         String arg0 = "";
         if (Arguments.Length > 0)
         {
             arg0 = Arguments[0];
         }
         Win32Util.SendString((IntPtr)Win32Util.HWND_BROADCAST, arg0);
     }
 }
 public CLYTViewer(CLYT Layout)
 {
     this.NWLayout = Layout;
     InitializeComponent();
     Win32Util.SetWindowTheme(treeView1.Handle, "explorer", null);
     Win32Util.SetWindowTheme(treeView2.Handle, "explorer", null);
 }
        ///////////////////////////////////////////////////////////////////////////////////////////////
        // Override(Event, Properties, Method...)
        ///////////////////////////////////////////////////////////////////////////////////////////////

        #region :: CreateItems :: Menu Item을 생성합니다.

        /// <summary>
        /// Menu Item을 생성합니다.
        /// </summary>
        protected override void CreateItems()
        {
            Items.Clear();
            string keyName = String.Format("{0}{1}", (View.GridControl.FindForm() as UIFrame).MenuID, View.Name);

            StringBuilder sb = new StringBuilder(128);

            Win32Util.GetPrivateProfileString("GridLayout", keyName, "", sb, 128, AppConfig.SETTINGFILEPATH);

            DXSubMenuItem columnsItem = new DXSubMenuItem("Columns");

            Items.Add(columnsItem);
            Items.Add(CreateMenuItem("컬럼 사용자지정", GridMenuImages.Column.Images[5], "Customization", true));

            //Items.Add(CreateMenuItem("컬럼 Layout 불러오기", null, "LayoutLoad", sb.ToString() == string.Empty || !File.Exists(sb.ToString()) ? false : true, true));
            Items.Add(CreateMenuItem("컬럼 Layout 저장", null, "LayoutSave", true));
            Items.Add(CreateMenuItem("컬럼 Layout 삭제", null, "LayoutDelete", sb.ToString() == string.Empty || !File.Exists(sb.ToString()) ? false : true));

            foreach (GridColumn column in View.Columns)
            {
                if (column.OptionsColumn.ShowInCustomizationForm)
                {
                    columnsItem.Items.Add(CreateMenuCheckItem(column.GetTextCaption(), column.VisibleIndex >= 0, null, column, true));
                }
            }
        }
Example #6
0
        /// <summary>
        /// 获得机器码
        /// </summary>
        /// <returns></returns>
        public static string GetMachineCode()
        {
            string s = "";

            byte[] macAddress = Win32Util.GetMacAddress();
            for (int i = 0; i < macAddress.Length; i++)
            {
                s = s + macAddress[i].ToString();
            }
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from Win32_BIOS");

            foreach (ManagementObject obj2 in searcher.Get())
            {
                s = s + obj2["Name"];
                s = s + obj2["BuildNumber"];
                s = s + obj2["Manufacturer"];
                s = s + obj2["SMBIOSBIOSVersion"];
            }
            byte[] bytes = new UnicodeEncoding().GetBytes(s);
            long   hash  = 0L;

            TeaEncrypt.TeaHash2(bytes, bytes.Length, out hash);
            bytes = BitConverter.GetBytes(hash);
            return(string.Format("{0,2:X}{1,2:X}-{2,2:X}{3,2:X}-{4,2:X}{5,2:X}-{6,2:X}{7,2:X}", new object[] { bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5], bytes[6], bytes[7] }).Replace('O', 'P').Replace('L', 'A').Replace('I', 'C').Replace('1', 'Z').Replace(' ', 'K'));
        }
Example #7
0
 private void LogMessage(string message)
 {
     Win32Util.ExecuteOrInvoke(this, () =>
     {
         labelMessage.Text = message;
     });
 }
Example #8
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            _context.Log.AddLogInformation("Вход в MainForm.FormLoad()");
            try
            {
                panelCancel.Visible = false;
                if (_package != null)
                {
                    _context.Log.AddLogInformation("Есть пакет для запуска");
                    buttonBrowse.Enabled = false;
                    panelCancel.Visible  = true;
                    Action action = new Action(_package.Execute);
                    _context.Log.AddLogInformation("Запускаем пакет");
                    ExecutePackageAsyncState state = new ExecutePackageAsyncState()
                    {
                        action  = action,
                        package = _package
                    };
                    action.BeginInvoke(execCallback, state);
                }
                else
                {
                    _context.Log.AddLogInformation("Нет пакета для запуска");
                    buttonBrowse.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                _context.Log.AddLogInformation("Поймано исключение в MainForm.FormLoad. Подробности смотрите далее.");
                _context.Log.AddLogException(ex);
                Win32Util.ShowError(this, "Ошибка при выполнении пакета. Подробности можно найти в журнале инсталлятора.");
            }

            _context.Log.AddLogInformation("Выход из MainForm.FormLoad()");
        }
Example #9
0
        protected override void WndProc(ref Message m)
        {
            bool flag = true;

            switch (m.Msg)
            {
            case 0x7b:
            {
                Point pointFromLPARAM = Win32Util.GetPointFromLPARAM((int)m.LParam);
                pointFromLPARAM = base.PointToClient(pointFromLPARAM);
                this.contextMenu1.Show(this, pointFromLPARAM);
                break;
            }

            case 0x31a:
                if (this.m_htheme != IntPtr.Zero)
                {
                    XPTheme.CloseThemeData(this.m_htheme);
                    this.m_htheme = IntPtr.Zero;
                }
                base.Invalidate();
                break;
            }
            if (flag)
            {
                base.WndProc(ref m);
            }
        }
        /// <summary>
        /// Menu Item Click Event를 정의합니다.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void OnMenuItemClick(object sender, EventArgs e)
        {
            if (RaiseClickEvent(sender, null))
            {
                return;
            }
            DXMenuItem item = sender as DXMenuItem;

            if (item.Tag == null)
            {
                return;
            }
            if (item.Tag is GridColumn)
            {
                GridColumn column = item.Tag as GridColumn;
                column.VisibleIndex = column.VisibleIndex >= 0 ? -1 : View.VisibleColumns.Count;
            }
            else if (item.Tag.ToString() == "Customization")
            {
                View.ColumnsCustomization();
            }
            else if (item.Tag.ToString() == "LayoutLoad")
            {
                try
                {
                    string keyName = String.Format("{0}{1}", (View.GridControl.FindForm() as UIFrame).MenuID, View.Name);

                    StringBuilder sb = new StringBuilder(128);
                    Win32Util.GetPrivateProfileString("GridLayout", keyName, "", sb, 128, AppConfig.SETTINGFILEPATH);
                    View.RestoreLayoutFromXml(sb.ToString());
                    //using (OpenFileDialog ofd = new OpenFileDialog { Filter = "XML 문서|*.xml", Multiselect = false })
                    //{
                    //    if (ofd.ShowDialog() == DialogResult.OK)
                    //        View.RestoreLayoutFromXml(ofd.FileName);
                    //}
                }
                catch (Exception ex)
                {
                    Win32Util.WritePrivateProfileString("GridLayout", (View.GridControl.FindForm() as UIFrame).MenuID + View.Name, "", AppConfig.SETTINGFILEPATH);
                    ExceptionHelper.ExceptionBox.Show(ex);
                }
            }
            else if (item.Tag.ToString() == "LayoutSave")
            {
                AppUtil.CreateFolder(AppConfig.GRIDLAYOUTFOLDER);
                string path = Path.Combine(AppConfig.GRIDLAYOUTFOLDER, String.Format("{0}.xml", View.Name));
                View.SaveLayoutToXml(path);
                Win32Util.WritePrivateProfileString("GridLayout", (View.GridControl.FindForm() as UIFrame).MenuID + View.Name, path, AppConfig.SETTINGFILEPATH);
                (View.GridControl.FindForm() as UIFrame).ShowAlertMessage("Layout 저장 완료", String.Format("{0}{1} Layout이 저장되었습니다.", path, Environment.NewLine), "");
            }
            else if (item.Tag.ToString() == "LayoutDelete")
            {
                if (MsgBox.Show("이전 저장된 Layout을 삭제하시겠습니까?", "삭제 확인", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    Win32Util.WritePrivateProfileString("GridLayout", (View.GridControl.FindForm() as UIFrame).MenuID + View.Name, "", AppConfig.SETTINGFILEPATH);
                }
            }
        }
Example #11
0
        void RenderPass(Common.Region dc, Common.Size ReqSize)
        {
            renderTime.Start();
            // Resize the form and backbuffer to noForm.Size
            Resize(ReqSize);

            Win32Util.Size w32Size = new Win32Util.Size((int)ReqSize.width, (int)ReqSize.height);
            Win32Util.SetWindowSize(w32Size, w32.handle);

            // Allow noform size to change as requested..like a layout hook (truncating layout passes with the render passes for performance)
            RenderSizeChanged(ReqSize);

            // Do Drawing stuff

            // 1) render to fbo
            throw new NotImplementedException();


// Create Color Texture
            uint ColorTexture;
            int  FboWidth  = (int)ReqSize.width;
            int  FboHeight = (int)ReqSize.height;

            GL.GenTextures(1, out ColorTexture);
            GL.BindTexture(TextureTarget.Texture2D, ColorTexture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Clamp);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Clamp);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba8, FboWidth, FboHeight, 0, PixelFormat.Rgba, PixelType.UnsignedByte, IntPtr.Zero);

            // create fbo
            uint FboHandle;

            GL.Ext.GenFramebuffers(1, out FboHandle);
            GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, FboHandle);
            GL.Ext.FramebufferTexture2D(FramebufferTarget.FramebufferExt, FramebufferAttachment.ColorAttachment0Ext, TextureTarget.Texture2D, ColorTexture, 0);

            // draw to fbo..?
            noForm.DrawBase(this, dc);
            // unbind fbo
            GL.Ext.BindFramebuffer(FramebufferTarget.FramebufferExt, 0); // return to visible framebuffer
            GL.DrawBuffer(DrawBufferMode.Back);

            // 2) go through dirty rects and copy to the window context
            throw new NotImplementedException();
            foreach (var dr in dc.AsRectangles())
            {
                //dostuff
            }

            // 3) call swapbuffers on window context...
            throw new NotImplementedException();

            currentFps = 1f / (float)renderTime.Elapsed.TotalSeconds;
            renderTime.Reset();
        }
Example #12
0
        private void InvokeLoadMainPackage()
        {
            Win32Util.ExecuteOrInvoke(this, () =>
            {
                panelCancel.Visible = true;
            });
            Action actionLoadMain = new Action(LoadMainPackage);

            actionLoadMain.BeginInvoke(LoadMainPackageCallback, actionLoadMain);
        }
Example #13
0
        static void Main(string[] Arguments)
        {
            if (Arguments.Length > 0 && Arguments[0].EndsWith(".efesc"))
            {
                if (!Win32Util.AttachConsole(-1))
                {
                    Win32Util.AllocConsole();
                }
                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
                PluginManager = new PluginManager();
                String   Script = File.ReadAllText(Arguments[0]);
                string[] args   = new string[Arguments.Length - 1];
                Array.Copy(Arguments, 1, args, 0, args.Length);
                Console.WriteLine();
                Console.WriteLine("Executing " + Path.GetFileName(Arguments[0]) + "...");
                EFEScript.Execute(Script, args);
                Win32Util.FreeConsole();
                //Using this causes scripts to be runned over and over again if opened by double-clicking
                //But without this, you need to press ENTER before be able to use the cmd again if you run it from there...
                //SendKeys.SendWait("{ENTER}");
                return;
            }

            if (mutex.WaitOne(TimeSpan.Zero, true))
            {
                AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
                PluginManager = new PluginManager();
                FileManager   = new FileManager();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                if (Arguments.Length > 0)
                {
                    Application.Run(new Form1(Arguments[0]));
                }
                else
                {
                    Application.Run(new Form1());
                }
            }
            else
            {
                String arg0 = "";
                if (Arguments.Length > 0)
                {
                    arg0 = Arguments[0];
                }
                foreach (var p in System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName))
                {
                    if (p != System.Diagnostics.Process.GetCurrentProcess())
                    {
                        Win32Util.SendString(/*(IntPtr)Win32Util.HWND_BROADCAST*/ p.MainWindowHandle, arg0);
                    }
                }
            }
        }
Example #14
0
 private void menuItemSavePackageAs_Click(object sender, EventArgs e)
 {
     try
     {
         SavePackageAs();
     }
     catch (Exception ex)
     {
         Win32Util.ShowError(this, "Не удалось сохранить пакет. Описание ошибки приведено далее. \r\n" + ex.Message + "\r\n" + ex.StackTrace);
     }
 }
Example #15
0
 private LanguageType GetDefaultLanguage()
 {
     try
     {
         var defaultLanguage = (LanguageType)Enum.Parse(typeof(LanguageType), Win32Util.GetSystemLanguage().ToString());
         return(defaultLanguage);
     }
     catch
     {
         return(LanguageType.en_us);
     }
 }
Example #16
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     try
     {
         ExecuteAsyncWithWait(InitMetadata, null, "Загрузка метаданных");
         listCommands.InitFromCommands(_metaData.Commands);
     }
     catch (Exception ex)
     {
         Win32Util.ShowError(this, "Не удалось запустить редактор пакетов. Описание ошибки приведено далее. \r\n" + ex.Message + "\r\n" + ex.StackTrace);
     }
 }
Example #17
0
        public void OnWinKeyboardInput(uint code, IntPtr wParam, IntPtr lParam)
        {
            if (!Initalized || !KeyboardEnabled)
            {
                return;
            }

            int  keyCode = Marshal.ReadInt32(lParam);
            uint type    = (uint)wParam.ToInt32();

            if (Window.Browser.IsDisposed)
            {
                return;
            }

            Window.Browser.Invoke(new Action(() => {
                IntPtr handle = Win32Util.GetForegroundWindow();

                if (!HandleUtil.DesktopAreaHandle.Equals(handle))
                {
                    return;
                }

                CefSharp.IBrowserHost host = Window.Browser.GetBrowser().GetHost();

                switch (type)
                {
                case Win32Util.WM_KEYDOWN:
                    host.SendKeyEvent(new KeyEvent()
                    {
                        WindowsKeyCode       = keyCode,
                        FocusOnEditableField = true,
                        Type        = KeyEventType.KeyDown,
                        IsSystemKey = false
                    });
                    break;

                case Win32Util.WM_KEYUP:
                    host.SendKeyEvent(new KeyEvent()
                    {
                        WindowsKeyCode       = keyCode,
                        FocusOnEditableField = true,
                        Type        = KeyEventType.KeyUp,
                        IsSystemKey = false
                    });
                    break;

                default: break;
                }
            }));
        }
Example #18
0
        protected void UnHookInput()
        {
            if (mouseHook != 0)
            {
                Win32Util.UnhookWindowsHookEx(mouseHook);
                mouseHook = 0;
            }

            if (keyboardHook != 0)
            {
                Win32Util.UnhookWindowsHookEx(keyboardHook);
                keyboardHook = 0;
            }
        }
Example #19
0
        private void MessageHelper_OnMessage(IList <Models.AddMsgList> msgs)
        {
            try
            {
                string msgStr = string.Empty;

                if (msgs != null && msgs.Count > 0)
                {
                    if (!isActived)
                    {
                        this.BeginInvoke(new Action(() =>
                        {
                            Win32Util.FlashWindow(this.Handle, true);
                        }));
                    }

                    foreach (var item in msgs)
                    {
                        if (!string.IsNullOrEmpty(item.Content))
                        {
                            var nickName = string.Empty;

                            var user = InitHelper.BatchGetContact.MemberList.Where(b => b.UserName == item.FromUserName).FirstOrDefault();

                            if (user == null)
                            {
                                var suser = InitHelper.WebWeixinInit.ContactList.Where(b => b.UserName == item.FromUserName).FirstOrDefault();
                                if (suser != null)
                                {
                                    nickName = suser.NickName;
                                }
                            }
                            else
                            {
                                nickName = user.NickName;
                            }
                            if (item.FromUserName == choose)
                            {
                                displayer.AppendMsg(nickName, item.Content);
                            }
                            MessageUtil.Set(item.FromUserName, Displayer.GenerateMsgHtml(nickName, item.Content));
                        }
                    }
                    displayer.GoBottom();
                }
            }
            catch (Exception ex)
            {
            }
        }
Example #20
0
            public object GetFontHandle(FontDesc fd)
            {
                Win32Util.LOGFONT lf = new Win32Util.LOGFONT();
                lf.lfFaceName = fd.Family;
                lf.lfHeight   = fd.Size;
                lf.lfItalic   = (byte)(fd.Style & FontStyle.Italic);
                if ((fd.Style & FontStyle.Bold) == FontStyle.Bold)
                {
                    lf.lfWeight = 700;
                }
                lf.lfItalic = (byte)(fd.Style & FontStyle.Underline);

                return(Win32Util.CreateFont(lf));
            }
Example #21
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            var hwnd = new WindowInteropHelper(this).Handle;

            var extendStyle = Win32Util.GetWindowLong(hwnd, -20);
            var newStyle    = extendStyle | 0x00000080 | 0x08000000;

            Win32Util.SetWindowLong(hwnd, -20, newStyle);
            Win32Util.SetWindowPos(hwnd, -1, 0, 0, 0, 0, 0x0010 | 0x0002); //TOPMOST SWP_NOACTIVATE NO_MOVE

            Height = SystemParameters.MaximizedPrimaryScreenHeight - 14;

            base.OnSourceInitialized(e);
        }
Example #22
0
        public bool stop()
        {
            bool succ = true;

            if (m_nativeHookPtr != IntPtr.Zero)
            {
                succ = Win32Util.UnhookWindowsHookEx(m_nativeHookPtr);
                Debug.Assert(succ == true, "Error removing the input hook!");
                m_nativeHookPtr         = IntPtr.Zero;
                m_managedCallbackObject = null;
            }
            Console.WriteLine("Input hook stopped.");
            return(succ);
        }
Example #23
0
 private void MenuItemExportClick(object sender, EventArgs e)
 {
     try
     {
         ChooseExportTypeForm form = new ChooseExportTypeForm();
         if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             SavePackage(_packageFilePath, form.GetResultContentType());
         }
     }
     catch (Exception ex)
     {
         Win32Util.ShowError(this, "Не удалось экспортировать пакет. Описание ошибки приведено далее. \r\n" + ex.Message + "\r\n" + ex.StackTrace);
     }
 }
Example #24
0
    // https://www.codeproject.com/Answers/1174965/How-can-I-make-my-form-like-windows-blurr-effect-o#answer3
    public static void enableBlur(this Form @this)
    {
        var accent = new Win32Util.AccentPolicy();

        accent.AccentState = Win32Util.AccentState.ACCENT_ENABLE_BLURBEHIND;
        var accentStructSize = Marshal.SizeOf(accent);
        var accentPtr        = Marshal.AllocHGlobal(accentStructSize);

        Marshal.StructureToPtr(accent, accentPtr, false);
        var Data = new Win32Util.WindowCompositionAttributeData();

        Data.Attribute  = Win32Util.WindowCompositionAttribute.WCA_ACCENT_POLICY;
        Data.SizeOfData = accentStructSize;
        Data.Data       = accentPtr;
        Win32Util.SetWindowCompositionAttribute(@this.Handle, ref Data);
        Marshal.FreeHGlobal(accentPtr);
    }
Example #25
0
 internal bool TryExportAttachment()
 {
     if (State.File.FrontCard.Attachment != null)
     {
         AttachmentFile attachment = State.File.FrontCard.Attachment;
         string         ext        = Path.GetExtension(attachment.Name);
         if (ext != "")
         {
             exportAttachmentDialog.Filter = string.Format(
                 Language.Get("ExportAttachmentFilter", "{1} (*.{0})|*.{0}|All files (*.*)|*"),
                 ext,
                 Win32Util.GetFileDescription(ext) ?? string.Format(Language.Get("UnknownExtension", "{0} File"), ext));
         }
         else
         {
             exportAttachmentDialog.Filter = Language.Get("ExportAttachmentFilterNoExt", "All files (*.*)|*");
         }
         exportAttachmentDialog.FileName = attachment.Name;
         DialogResult result = exportAttachmentDialog.ShowDialog();
         if (result == DialogResult.OK)
         {
             string filePath = exportAttachmentDialog.FileName;
             try
             {
                 UseWaitCursor = true;
                 File.WriteAllBytes(filePath, attachment.Data);
             }
             catch (IOException)
             {
                 MessageBox.Show(
                     this,
                     Language.Get("CannotExportAttachment", "An error occurred while exporting the attachment. Make sure the file is not read-only and that you have sufficient disk space."),
                     this.ProgramName,
                     MessageBoxButtons.OK,
                     MessageBoxIcon.Hand);
             }
             finally
             {
                 UseWaitCursor = false;
             }
             return(true);
         }
         return(false);
     }
     return(false);
 }
Example #26
0
        public void BeginRender()
        {
            // Make sure it gets layered!
            hWnd = w32.handle;
            var wl  = Win32Util.GetWindowLong(hWnd, Win32Util.GWL_EXSTYLE);
            var ret = Win32Util.SetWindowLong(hWnd, Win32Util.GWL_EXSTYLE, wl | Win32Util.WS_EX_LAYERED);

            // hook move!
            noForm.LocationChanged += noForm_LocationChanged;

            // Start the watcher
            dobs.Dirty(noForm.DisplayRectangle);
            dobs.running = true;
            dobs.StartObserving();

            noForm_LocationChanged(noForm.Location);
        }
Example #27
0
        static void Main()
        {
#if false
            App.DrawOnScreenTest();
#endif

            SPMouse.Settings settings = new SPMouse.Settings();
            settings.sRopeLength = 128;
            settings.sDarkgray   = Color.FromArgb(255, 32, 32, 32);
            settings.sLightgray  = Color.FromArgb(255, 128, 128, 128);
            settings.sLightgray  = Color.FromArgb(255, 128, 128, 128);
            settings.sAccent     = Win32Util.GetThemeColor();

            Application.EnableVisualStyles(); //Enable Win10 Styling
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new SPMouse(settings));
        }
Example #28
0
 private void MenuItemOpenPackageClick(object sender, EventArgs e)
 {
     try
     {
         OpenFileDialog dialog = new OpenFileDialog();
         DialogResult   result = dialog.ShowDialog();
         if (result == DialogResult.OK)
         {
             _packageFilePath = dialog.FileName;
             ExecuteAsyncWithWait(() => LoadPackage(_packageFilePath), null, "Загрузка пакета");
         }
     }
     catch (Exception ex)
     {
         Win32Util.ShowError(this, "Не удалось открыть пакет. Описание ошибки приведено далее. \r\n" + ex.Message + "\r\n" + ex.StackTrace);
     }
 }
Example #29
0
 private void menuItemSavePackage_Click(object sender, EventArgs e)
 {
     try
     {
         if (_packageFilePath == null)
         {
             SavePackageAs();
         }
         else
         {
             SavePackage(_packageFilePath, PackageContentType.Empty);
         }
     }
     catch (Exception ex)
     {
         Win32Util.ShowError(this, "Не удалось сохранить пакет. Описание ошибки приведено далее. \r\n" + ex.Message + "\r\n" + ex.StackTrace);
     }
 }
Example #30
0
        void RenderPass(Common.Region dc, Common.Size ReqSize)
        {
            renderTime.Start();
            // Resize the form and backbuffer to noForm.Size
            Resize(ReqSize);

            Win32Util.Size w32Size = new Win32Util.Size((int)ReqSize.width, (int)ReqSize.height);
            Win32Util.SetWindowSize(w32Size, winHandle); // FIXME blocks when closing->endrender event is locked...

            // Allow noform size to change as requested..like a layout hook (truncating layout passes with the render passes for performance)
            RenderSizeChanged(ReqSize);

            // Do Drawing stuff
            DrawingSize rtSize = new DrawingSize((int)d2dRenderTarget.Size.Width, (int)d2dRenderTarget.Size.Height);

            using (Texture2D t2d = new Texture2D(backBuffer.Device, backBuffer.Description))
            {
                using (Surface1 srf = t2d.QueryInterface <Surface1>())
                {
                    using (RenderTarget trt = new RenderTarget(d2dFactory, srf, new RenderTargetProperties(d2dRenderTarget.PixelFormat)))
                    {
                        _backRenderer.renderTarget = trt;
                        trt.BeginDraw();
                        noForm.DrawBase(this, dc);
                        trt.EndDraw();

                        foreach (var rc in dc.AsRectangles())
                        {
                            t2d.Device.CopySubresourceRegion(t2d, 0,
                                                             new ResourceRegion()
                            {
                                Left = (int)rc.left, Right = (int)rc.right, Top = (int)rc.top, Bottom = (int)rc.bottom, Back = 1, Front = 0
                            }, backBuffer, 0,
                                                             (int)rc.left, (int)rc.top, 0);
                        }
                    }
                }
            }
            swapchain.Present(0, PresentFlags.None);

            //System.Threading.Thread.Sleep(1000);
            lastFrameRenderDuration = 1f / (float)renderTime.Elapsed.TotalSeconds;
            renderTime.Reset();
        }