Пример #1
0
        static internal EmulatorDisplay Create(string filePath, int width, int height)
        {
            if (!System.IO.File.Exists(filePath))
            {
                try{
                    EmulatorDisplay dd = new EmulatorDisplay(filePath);

                    dd.Width  = width;
                    dd.Height = height;

                    dd.Author = "Moscrif Ide Generator";
                    dd.Title  = System.IO.Path.GetFileName(filePath);
                    dd.Url    = "";
                    dd.Save();
                    return(dd);
                }catch (Exception ex) {
                    MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error"), ex.Message, Gtk.MessageType.Error);
                    md.ShowDialog();
                    return(null);
                }
            }
            else
            {
                //throw new FileNotFoundException();
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error"), MainClass.Languages.Translate("file_notcreate_is_exist"), Gtk.MessageType.Error);
                md.ShowDialog();
                return(null);
            }
        }
Пример #2
0
        //table1
        public DevicesOptionsWidget(Gtk.Window parent)
        {
            parentWindow = parent;
            this.Build();
            //ComboBox cbResolution = new ComboBox();

            //table1.Attach(cbResolution,1,2,0,1);
            CellRendererText textRenderer = new CellRendererText();

            //cbResolution.PackStart(textRenderer, true);

            cbResolution.AddAttribute(textRenderer, "text", 0);

            cbResolution.Model=resolStore;

            tvFiles.AppendColumn(MainClass.Languages.Translate("file"), new Gtk.CellRendererText(), "text", 0);
            tvFiles.AppendColumn(MainClass.Languages.Translate("path"), new Gtk.CellRendererText(), "text", 1);

            string[] listFi = Directory.GetFiles(MainClass.Paths.DisplayDir, "*.ini");
            foreach (string fi in listFi){
                EmulatorDisplay dd = new EmulatorDisplay(fi);
                if (dd.Load()){
                    fileListStore.AppendValues(System.IO.Path.GetFileName(fi),fi,dd);
                }
            }

            foreach (Rule rl in MainClass.Settings.Resolution.Rules ){
                resolStore.AppendValues(String.Format("{0} ({1}x{2})",rl.Name,rl.Width,rl.Height),rl.Id,rl.Name,rl.Specific,rl);
            }

            tvFiles.Model = fileListStore;

            tvFiles.Selection.Changed += delegate(object sender, EventArgs e)
            {
                if(isChange){
                    Save(true);
                }

                selectedResolDisplay = GetSelectedDevicesDisplay();
                if (selectedResolDisplay == null ) return;

                sbHeight.Value = selectedResolDisplay.Height;
                sbWidth.Value =selectedResolDisplay.Width;

                entTitle.Text =selectedResolDisplay.Title;
                entAuthor.Text =selectedResolDisplay.Author;
                entUrl.Text =selectedResolDisplay.Url;
                chbTablet.Active =selectedResolDisplay.Tablet;

                Rule rlr = MainClass.Settings.Resolution.Rules.Find(x=>x.Height==selectedResolDisplay.Height && x.Width== selectedResolDisplay.Width);

                if(rlr != null){
                    TreeIter ti = new TreeIter();
                    bool isFind = false;
                    resolStore.Foreach((model, path, iterr) => {
                        Rule ruleIter = (Rule)resolStore.GetValue(iterr, 4);

                        if (ruleIter == rlr){
                            ti = iterr;
                            isFind = true;
                            return true;
                        }
                            return false;
                    });
                    if(isFind)
                        cbResolution.SetActiveIter(ti);
                    else cbResolution.Active =0;
                }
                isChange = false;
            };
            cbResolution.Changed += delegate(object sender, EventArgs e) {
                TreeIter ti = new TreeIter();
                if(cbResolution.GetActiveIter(out ti)){
                    Rule ruleIter = (Rule)resolStore.GetValue(ti, 4);
                    sbHeight.Value= ruleIter.Height;
                    sbWidth.Value= ruleIter.Width;
                }

            };
        }
Пример #3
0
        public void ShowWidget()
        {
            isChange = false;
            TreeSelection ts = tvFiles.Selection;

            TreePath[] tp = ts.GetSelectedRows();

            fileListStore.Clear();
            string[] listFi = Directory.GetFiles(MainClass.Paths.DisplayDir, "*.ini");
            foreach (string fi in listFi){
                EmulatorDisplay dd = new EmulatorDisplay(fi);
                if (dd.Load()){
                    fileListStore.AppendValues(System.IO.Path.GetFileName(fi),fi,dd);
                }
            }

            resolStore.Clear();
            foreach (Rule rl in MainClass.Settings.Resolution.Rules ){
                resolStore.AppendValues(String.Format("{0} ({1}x{2})",rl.Name,rl.Width,rl.Height),rl.Id,rl.Name,rl.Specific,rl);
            }

            isChange = false;
            if (tp.Length < 1){
                TreeIter ti = new TreeIter();
                if(fileListStore.GetIterFirst(out ti)){
                    ts.SelectIter(ti);
                }
            } else {
                ts.SelectPath(tp[0]);
            }
        }
Пример #4
0
        internal static EmulatorDisplay Create(string filePath,int width,int height)
        {
            if (!System.IO.File.Exists(filePath)) {

                try{
                    EmulatorDisplay dd = new EmulatorDisplay(filePath);

                    dd.Width = width;
                    dd.Height = height;

                    dd.Author = "Moscrif Ide Generator";
                    dd.Title = System.IO.Path.GetFileName(filePath);
                    dd.Url ="";
                    dd.Save();
                    return dd;

                }catch(Exception ex){
                    MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error"), ex.Message, Gtk.MessageType.Error);
                    md.ShowDialog();
                    return null;

                }
            } else {
                //throw new FileNotFoundException();
                MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("error"),  MainClass.Languages.Translate("file_notcreate_is_exist"), Gtk.MessageType.Error);
                md.ShowDialog();
                return null;
            }
        }
Пример #5
0
    private void FillResolution(int device, bool allResolution)
    {
        bool isFind = false;
        bool hardAll  = false;
        ddbResolution.Clear();

        string path="";
        if(MainClass.Workspace!= null)
            path = MainClass.Workspace.ActualResolution;

        string[] listFi = Directory.GetFiles(MainClass.Paths.DisplayDir, "*.ini");
        string vvgaPath = System.IO.Path.Combine(MainClass.Paths.DisplayDir,"noskin_vga.ini");

        PlatformResolution pr = MainClass.Settings.PlatformResolutions.Find(x=>x.IdPlatform == device);
        if(pr == null){
            hardAll = true; // nema definiciu , zobrazuju sa vsetky
        }
        DropDownButton.ComboItem selectComboItem = null;
        DropDownButton.ComboItem vvgaComboItem = null;

        foreach (string fi in listFi) {
            EmulatorDisplay dd = new EmulatorDisplay(fi);
            if (dd.Load()) {

                if((!allResolution) && (!hardAll)){
                    Rule rlr = MainClass.Settings.Resolution.Rules.Find(x=>x.Height==dd.Height && x.Width== dd.Width);
                    if((rlr!= null) && device >-1){
                        if(!pr.IsValidResolution(rlr.Id)){
                            continue;
                        }
                    }
                }

                DropDownButton.ComboItem addComboItem = new DropDownButton.ComboItem(dd.Title,dd.FilePath);
                resolutionItems.Add(addComboItem);

                if(dd.FilePath == vvgaPath){
                    vvgaComboItem = addComboItem;
                }

                if (dd.FilePath == path) {
                    isFind = true;
                    selectComboItem = addComboItem;
                }
            }
        }

        if (isFind)
            ddbResolution.SelectItem(resolutionItems,selectComboItem);
        else{
            if(vvgaComboItem != null){
                ddbResolution.SelectItem(resolutionItems,vvgaComboItem);
            } else {
                if(resolutionItems.Count>0){
                    ddbResolution.SelectItem(resolutionItems,resolutionItems[0]);
                }
            }
        }

        if(!hardAll){
            if(!allResolution){
                resolutionItems.Add(new DropDownButton.ComboItem(MainClass.Languages.Translate("show_denied" ) , "-1") );
            } else {
                resolutionItems.Add(new DropDownButton.ComboItem(MainClass.Languages.Translate("hide_denied" ) , "-2") );
            }
        }
    }
Пример #6
0
        private void EditRule()
        {
            TreeSelection ts = tvResolution.Selection;

            TreeIter ti = new TreeIter();
            ts.GetSelected(out ti);

            TreePath[] tp = ts.GetSelectedRows();
            if (tp.Length < 1)
                return ;

            Rule cd = (Rule)tvResolution.Model.GetValue(ti, 3);
            if (cd == null) return;

            if(cd.Id ==-1){
                MessageDialogs mdError = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("edit_resolution_system"), "", Gtk.MessageType.Error,parentWindow);
                mdError.ShowDialog();
                return;
            }

            int width= cd.Width;
            int height =cd.Height;

            ResolutionDialog ed = new ResolutionDialog(cd,parentWindow);
            int result = ed.Run();
            if (result == (int)ResponseType.Ok){
                Rule res = ed.Resolution;
                if (res!= null ){

                    Rule cdFind = MainClass.Settings.Resolution.Rules.Find(x=>x.Id ==res.Id);
                    if (cdFind == null){

                        MessageDialogs md = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, MainClass.Languages.Translate("resolution_is_exist", cdFind.Name), "", Gtk.MessageType.Error,parentWindow);
                        md.ShowDialog();
                        ed.Destroy();
                        return;
                    }
                    cdFind = res;
                    resolStore.SetValues(ti,cdFind.Id,cdFind.Name,cdFind.Specific,cdFind);

                    try{
                        string[] listFi = Directory.GetFiles(MainClass.Paths.DisplayDir, "*.ini");

                        foreach (string fi in listFi){
                            EmulatorDisplay dd = new EmulatorDisplay(fi);
                            if (dd.Load()){
                                if (dd.Height == height && dd.Width == width){
                                    dd.Height = res.Height;
                                    dd.Width = res.Width;
                                    dd.Save();
                                }
                            }
                        }

                    }catch(Exception ex){
                        Tool.Logger.Error(ex.Message,null);
                        MessageDialogs ms = new MessageDialogs(MessageDialogs.DialogButtonType.Ok, "Error", ex.Message, MessageType.Error,parentWindow);
                        ms.ShowDialog();
                        return;
                    }
                }
            }
            ed.Destroy();
        }